$ aws ec2 describe-volumes \
--query 'Volumes[*].{ID:VolumeId,InstanceId:Attachments[0].InstanceId,AZ:AvailabilityZone,Size:Size}'
[
{
"InstanceId": "i-a071c394",
A curated list of AWS resources to prepare for the AWS Certifications
A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.
The security group and Network ACLs parts of CloudFormation templates can be difficult to read. This template containing Jinja macros converts easier-to-read YAML dictionaries of security group and NACL rules into JSON.
Here ais a generic macro template and some example files showing how to use it.
- cloudformation.macros.j2 - the macros
- cf_vars.yml - YAML dictionaly of security groups and NACLs, including some complex rules for both
- test.template.j2 - a simple CloudFormation template that uses the macro file
- cf_test.yml - a simple Ansible playbook that generates CloudFormation JSON from thr previous file.
This file contains 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 | |
import datetime | |
def lambda_handler(event, context): | |
print("Connecting to RDS") | |
client = boto3.client('rds') | |
print("RDS snapshot backups stated at %s...\n" % datetime.datetime.now()) | |
client.create_db_snapshot( | |
DBInstanceIdentifier='web-platform-slave', |
This file contains 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
#!/usr/bin/env python | |
# Based on the script found here: http://cloudbuzz.wordpress.com/2011/02/15/336/ | |
from boto.ec2 import EC2Connection | |
csv_file = open('instances.csv','w+') | |
def process_instance_list(connection): | |
map(build_instance_list,connection.get_all_instances()) |
This file contains 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
wget http://stedolan.github.io/jq/download/linux64/jq | |
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \ | |
"Name=instance-state-name,Values=running" \ | |
| jq -r \ | |
".Reservations[] | .Instances[] | .InstanceId" \ | |
aws ec2 describe-volumes --filters \ | |
"Name=status,Values=available" \ | |
| jq -r ".Volumes[] | .VolumeId" \ |
NewerOlder