DEV Community

Cover image for Day 13.Create AMI from EC2 Instance
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

Day 13.Create AMI from EC2 Instance

Lab Information

The Nautilus DevOps team is strategizing the migration of a portion of their infrastructure to the AWS cloud. Recognizing the scale of this undertaking, they have opted to approach the migration in incremental steps rather than as a single massive transition. To achieve this, they have segmented large tasks into smaller, more manageable units. This granular approach enables the team to execute the migration in gradual phases, ensuring smoother implementation and minimizing disruption to ongoing operations. By breaking down the migration into smaller tasks, the Nautilus DevOps team can systematically progress through each stage, allowing for better control, risk mitigation, and optimization of resources throughout the migration process.

For this task, create an AMI from an existing EC2 instance named devops-ec2 with the following requirement:

Name of the AMI should be devops-ec2-ami, make sure AMI is in available state.

Lab Solutions

Step-by-Step Instructions (AWS Console)

  1. Log in to AWS Console

Use your lab credentials and ensure the region is us-east-1.

  1. Navigate to the EC2 Instance

Go to EC2 service

Click Instances

Find and select the instance named devops-ec2

Ensure:

It is in running state (recommended)

  1. Create the AMI

With devops-ec2 selected:

Click Actions

Select Image and templates

Click Create image

A form will appear.

Fill in the required details:

Image name: devops-ec2-ami

Image description: (optional)

No reboot:

Default (reboot allowed) is safer and recommended.

Click Create image

AWS will now start generating the AMI.

  1. Verify AMI Creation

Go to Images → AMIs in the left EC2 menu.

Ensure Owned by me is selected.

Find AMI named devops-ec2-ami

Initially, the State will show:

pending

Wait until it becomes:

available

This may take a few minutes depending on instance size.


Resources & Next Steps


Credits

  • All labs are from: KodeKloud
  • Thanks for providing them.

Top comments (2)

Collapse
 
hunter81 profile image
Hunter81 • Edited

That's a great post! I recently tried creating an AMI (Amazon Machine Image) from one of my instances, and I ran into an issue with the completion time.The instance was a t4.2xlarge with a significant amount of data, and the AMI creation process stayed in the "pending" state for hours. I eventually stopped the process because it seemed stuck.I'm wondering if anyone has experience with this size of instance: What is the normal expected time for an AMI created from a t4.2xlarge to transition to the "available" state?Any insights into factors that drastically increase this time (like large root volumes, number of attached EBS volumes, etc.) would be really helpful!

Collapse
 
thukhakyawe_cloud profile image
Thu Kha Kyawe

In my experience, it seems like “stuck” while it's actually still working in the background.

  1. Small-to-medium instances (8–200 GB total data) Usually 5–20 minutes.

With large volume < 500GB
Commonly 30–120 minutes.

AWS does not base AMI creation time on instance type (t4g, m5, r5, etc.).
The limiting factor is EBS snapshot creation time, not CPU or RAM.
So the fact your instance was a t4.2xlarge doesn’t reduce snapshot time at all.

Note: The very first snapshot is always the slowest, since AWS must copy all used blocks.Future snapshots are incremental and much faster.

Check EBS volume, must gp3.
And Create EBS snapshots manually.
Then register an AMI from the snapshots.