Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a EC2 instance from snapshot in cloudformation?

I'd like to specify the snapshot id which would be used to create a root device image for a EC2 instance created with cloudformation. How do I do that?

I could only find a way to make volume from a snapshot, but no way to use it in the instance.

like image 359
Fluffy Avatar asked Aug 13 '12 14:08

Fluffy


People also ask

Can we create EC2 instance from snapshot?

To create an AMI from a snapshot using the consoleOpen the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Snapshots. Select the snapshot from which to create the AMI and choose Actions, Create image from snapshot.

How do I create an instance of a snapshot?

Search for the snapshot that you want to restore, and select it. Choose Actions, and then choose Create Volume. Create the new volume in the same Availability Zone as your EC2 instance. On the Amazon EC2 console, select the instance.


1 Answers

If you want to use an EBS snapshot as the basis of the root disk (EBS volume) for an instance, you need to first register the snapshot as an AMI (e.g., using ec2-register).

Make sure to specify the correct architecture and kernel (AKI) when you register the snapshot as an AMI.

Alternatively, instead of taking a snapshot and registering it as separate steps, you could use the ec2-create-image command/API/console function to perform the snapshot and registration in a single step. This also takes care of picking the right architecture, kernel, and other parameters.

Once you have an AMI, you can tell CloudFormation to use that AMI when running a new instance.

like image 190
Eric Hammond Avatar answered Nov 01 '22 07:11

Eric Hammond