ryekayo ryekayo - 3 days ago 4
JSON Question

Can I get metadata from an EC2 that was not made in CloudFormation?

I have instances that were not created by CloudFormation. I am hoping to replicate those instances but I do not want to go through the whole brain numbing process of building the instances in EC2 (going through the steps of specifying the instance type, EBS volumes, etc.). My questions are:

  • Is there a way to get ALL the metadata of the EC2 instance from the AWS CLI in a JSON format that I can pass off to a creation of a new stack?

  • If so, can someone provide references in doing so?

  • If the CLI is not an option, is there any way of going through the AWS console to get this information?

It would be so cool if they had a way of doing some kind of JSON dump similar to a database dump.


You could start with:

aws ec2 describe-instances \
    --instance-ids "i-06666777788889999" \
    --query "Reservations[0]"

You'd then also probably want to get details of attached EBS volumes, Security Groups etc.

Alternatively, see if CloudFormer can help you. It can create a CloudFormation template from AWS resources that you point it at.