Posts Tagged ‘Amazon AWS’

AWS’s S3 outage was so bad Amazon couldn’t get into its own dashboard to warn the world. https://www.theregister.co.uk/2017/03/01/aws_s3_outage/

Advertisements

To get AMI ID with tags

aws ec2 describe-images –filter Name=tag:amitype,Values=autoscale –output text | grep -i ami | awk ‘{ print  $5, $7 }’ | awk ‘NR==1{print $1}’

Modify the “Name=tag:amitype,Values=autoscale” Section with your own tags.

Find Snapshots associated with an AMI

aws ec2 describe-images –image-ids <amiid> –output text –query Images[*].BlockDeviceMappings[*].Ebs.SnapshotId’

Replace “<amiid>” with the AMI ID you need.

To Deregister an AMI

aws ec2 deregister-image –image-id <amiid>

Replace “<amiid>” with the AMI ID you need to deregister.

To remove a snapshot 

aws ec2 delete-snapshot –snapshot-id <snapshot_id>

Replace “<snapshot_id>” with the Snapshot ID you need to remove.

 

Bash script to remove AMI’s older than 7 days and Snapshots associated with this AMI’s – link