This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Get the current manifest of the ECR image ecrimage-800 | |
| MANIFEST=$(aws ecr batch-get-image --repository-name ecrimage-800 --image-ids imageTag=latest --query 'images[].imageManifest' --output text) | |
| echo $MANIFEST | jq '.' | |
| //Push the tag called newtag along with image manifest. | |
| aws ecr put-image --repository-name ecrimage-800 --image-tag newtag --image-manifest "$MANIFEST" | |
| //Now ecrimage-800 will have two tags, "latest" and "newtag". You are ready to remove "latest" tag if you like. | |
| aws ecr batch-delete-image --repository-name ecrimage-800 --image-ids imageTag=latest | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # all logging settins are here on top | |
| $logFile = "log-$(gc env:computername).log" | |
| $logLevel = "DEBUG" # ("DEBUG","INFO","WARN","ERROR","FATAL") | |
| $logSize = 1mb # 30kb | |
| $logCount = 10 | |
| # end of settings | |
| function Write-Log-Line ($line) { | |
| Add-Content $logFile -Value $Line | |
| Write-Host $Line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| import boto3 | |
| """ | |
| A tool for retrieving basic information from the running EC2 instances. | |
| """ | |
| # Connect to EC2 | |
| ec2 = boto3.resource('ec2') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import boto3 | |
| from boto3.dynamodb.conditions import Key, Attr | |
| from datetime import datetime | |
| from pytz import timezone | |
| import os | |
| import json | |
| # Here we assign our aws clients/resources to use | |
| ses_client = boto3.client('ses') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| schemaVersion: '2.2' | |
| description: Sets computer name for computer(s) that is(are) part of the domain, using the value of Name tag for the selected resource(s). | |
| mainSteps: | |
| - action: aws:runPowerShellScript | |
| name: setComputerNameFromTag | |
| precondition: | |
| StringEquals: | |
| - platformType | |
| - Windows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # set variable AWS_PROFILE= to credentials | |
| import boto3 | |
| # CHANGE REGION HERE- | |
| ec2 = boto3.resource('ec2', 'sa-east-1') | |
| #check your own tags before run this script | |
| #loop for tag Name | |
| def tag_name(): | |
| print "Loop for TAG Name" | |
| for volume in ec2.volumes.all(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| def lambda_handler(event, context): | |
| is_test = context.function_name == 'test' # this value is injected by SAM local | |
| instances = boto3.resource('ec2').instances.all() | |
| copyable_tag_keys = ["Team", "Billing", "BillingTag", "Env", "Project"] | |
| for instance in instances: | |
| copyable_tags = [t for t in instance.tags |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # most credit to the original: https://gist.github.com/brandond/6b4d22eaefbd66895f230f68f27ee586 | |
| # Tag snapshots based on their associated AMI and volumes based on attached instance. | |
| # format: | |
| # (AMI:db5|db5) /dev/sda1 (1/4) | |
| # (AMI:db5|db5) /dev/sdb (2/4) | |
| # Best practice: create IAM user | |
| # Simplest privilege to get it to work with reasonable security: use predefined policy "ReadOnlyAccess" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import copy | |
| import logging | |
| import os | |
| import boto3 | |
| logging.basicConfig(level=os.environ.get('LOG_LEVEL', 'INFO')) | |
| ec2 = boto3.client('ec2') | |
| logger = logging.getLogger(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' quick example showing how to attach a pdf to multipart messages | |
| and then send them from SES via boto | |
| ''' | |
| from email.mime.text import MIMEText | |
| from email.mime.application import MIMEApplication | |
| from email.mime.multipart import MIMEMultipart | |
| import boto |
NewerOlder