DEV Community

Cover image for πŸ“Έ AWS 113: Capturing the Moment - How to Create an Amazon Machine Image (AMI)
Hritik Raj
Hritik Raj

Posted on

πŸ“Έ AWS 113: Capturing the Moment - How to Create an Amazon Machine Image (AMI)

AWS

πŸ–ΌοΈ AWS AMIs: Creating a "Golden Image" of Your Server

Hey Cloud Visionaries! πŸ‘‹

Welcome to Day 13 of the #100DaysOfCloud Challenge: Create AMI! We are continuing our systematic infrastructure migration with KodeKloud Engineer. Today, we are learning how to "freeze time" and save our server configuration forever.

Our mission: Create an AMI named devops-ec2-ami from the existing EC2 instance named devops-ec2 in the us-east-1 region.


1. Introduction: What is an AMI? πŸ’‘

Think of an Amazon Machine Image (AMI) as a blueprint or a snapshot of your entire server.

  • Golden Image: Once you spend hours installing software and configuring settings on a server, you don't want to do it again! An AMI saves all of that.
  • Mass Replication: You can use one AMI to launch 1, 10, or 100 identical servers in minutes.
  • Disaster Recovery: If your server gets corrupted, you can launch a fresh one from your AMI and be back online instantly.

Let's take a "photo" of our devops-ec2 instance! πŸ“Έ


2. Step-by-Step Guide: Creating the devops-ec2-ami

We will use the EC2 Dashboard to create this image.

Step 2.1: Locate your Instance

  1. Log in to the AWS Console and navigate to the EC2 Dashboard.

  1. Click on "Instances (running)".

  1. Find the instance named devops-ec2.

Step 2.2: Create the Image

  1. Select the devops-ec2 checkbox.
  2. Click the "Actions" button at the top.
  3. Navigate to "Image and templates" -> "Create image".

  1. On the Create image page:

    • Image name: Enter devops-ec2-ami.
    • Description: (Optional) "Backup of our devops server."
    • Leave everything else as default (AWS will automatically snapshot any attached EBS volumes).
  2. Click "Create image".

Step 2.3: Verify the AMI State

  1. In the left sidebar of the EC2 Dashboard, under "Images", click on "AMIs".

  1. Your new AMI will appear there. Its status will initially be "pending".

  1. Refresh after a few minutes until the status turns to 🟒 "available".

Success! You now have a reusable blueprint of your DevOps server. πŸŽ‰


3. Key Takeaways πŸ“

  • Snapshots Included: When you create an AMI, AWS automatically creates snapshots of all the EBS volumes attached to that instance.
  • No-Reboot Option: By default, AWS reboots the instance during image creation to ensure data consistency. You can check "No reboot" to keep it online, but the image might be less consistent.
  • Regional Resource: AMIs are regional. If you need this image in London, you have to "Copy" the AMI to that region.

4. Common Mistakes to Avoid 🚫

  1. Storage Costs: Remember that you are charged for the snapshots stored behind the AMI. Don't keep hundreds of old AMIs you don't need!
  2. Deleting the Source: You can delete the original devops-ec2 instance, and the AMI will still work perfectly.
  3. Deregistering: If you want to delete an AMI, you must "Deregister" it and then manually delete the associated Snapshots to stop billing.

5. Conclusion + Call to Action! 🌟

Standardizing your environment with AMIs is a hallmark of a professional DevOps workflow. By creating devops-ec2-ami, you’ve ensured that the Nautilus team can scale their operations with total consistency.

How are you enjoying the 100 Days of Cloud Challenge? πŸ›‘οΈ

  • πŸ’¬ Let’s connect on LinkedIn: Have you ever used "Packer" to automate your AMI creation? πŸ‘‰ Hritik Raj
  • ⭐ Support my journey on GitHub: Check out my progress as I move through all 100 days. πŸ‘‰ GitHub – 100 Days of Cloud

Top comments (0)