Get A List of EC2 Instances And The AMIs Used to Launch Them
2021-06-12
I was recently tasked with auditing the AMIs we are currently using for our AWS account. I could have just checked all machines but thought jq might be a better way to do it, and it actually is.
aws ec2 describe-instances --profile env-dev-poweruser | jq -r '.Reservations[].Instances[0] | with_entries(select([.key] | inside(["InstanceId", "ImageId"]))) | [.InstanceId, .ImageId] | join("\n")'
This uses the aws cli tool to pull instance information, then uses jq to filter out the field we don’t need.
About Me
Dev gone Ops gone DevOps. Any views expressed on this blog are mine alone and do not necessarily reflect the views of my employer.