Skip to main content

Adding a Custom AWS AMI for VM Labs

How to create a custom AMI (Amazon Machine Image) in AWS to serve as a template for Vocareum Virtual Machine Labs

M
Written by Mary Gordanier
Updated over a week ago

For Admins

Introduction

This guide walks you through creating a custom Amazon Machine Image (AMI) in AWS and making it available in Vocareum.

An AMI is essentially a template that contains the software configuration (operating system, applications, settings) needed to launch an EC2 instance. Creating a custom AMI allows you to:

  • Save the current state of an EC2 instance for backup purposes.

  • Create a reusable template for launching multiple identical instances.

  • Distribute pre-configured Virtual Machines (VMs) across your organization.

Prerequisites:

  • Admin access to a Vocareum organization.

  • Virtual Machine Labs enabled and an AWS account connected to your Vocareum Organization. Contact support@vocareum.com for assistance with this setup.

  • An existing EC2 instance that you want to create an AMI from (or you can launch a new one).


Accessing the EC2 Dashboard

Step 1: Log into the AWS Management Console

  1. Open the Org Settings page for your Vocareum Organization.

  2. Navigate to the section titled Custom Infrastructure.

  3. Scroll to the sub-section titled VM Settings.

  4. Click the View button next to the option labeled AWS Console.

This will open the AWS Console for the account connected to your Vocareum Organization for Virtual Machine labs.

Step 2: Navigate to the EC2 Service

Once you're logged in, you'll see the AWS Management Console home screen, which displays various AWS services.

  1. In the search bar at the top of the page, type EC2

  2. Click on EC2 from the dropdown results (the subtitle should say "Virtual Servers in the Cloud")

Alternative method: You can also find EC2 under the "Services" menu in the top left, under the "Compute" category.

[Screenshot: AWS Console home screen with EC2 search highlighted]


Selecting the Instance for Your AMI

Step 3: View Your EC2 Instances

You should now be on the EC2 Dashboard. This is the main control panel for managing virtual servers in AWS.

  1. In the left sidebar menu, locate and click on Instances

  2. You'll see a list of all EC2 instances in your current region

What you're seeing: Each row represents a virtual server. The list shows important information like:

  • Instance ID (a unique identifier starting with "i-")

  • Instance State (running, stopped, etc.)

  • Instance Type (the size/capacity of the server)

  • Availability Zone (which data center it's in)

[Screenshot: EC2 Dashboard showing the Instances link in the left sidebar]

Step 4: Choose the Instance to Create an AMI From

  1. Review your list of instances and identify the one you want to create an AMI from

  2. Click the checkbox next to the instance you want to use

Alternative method:

Important Notes:

  • You can create an AMI from either a running or stopped instance

  • Creating an AMI from a running instance is possible but may result in data inconsistency if files are being written during the process

  • Best Practice: Stop the instance before creating an AMI to ensure data consistency and a clean snapshot

[Screenshot: EC2 Instances list with one instance selected via checkbox]

Step 5: Stop the Instance (Recommended)

If your instance is currently running and you want to ensure data consistency:

  1. With the instance selected, click the Instance state dropdown button at the top

  2. Select Stop instance

  3. In the confirmation dialog, click Stop

  4. Wait for the instance state to change to "Stopped" (this may take 1-2 minutes)

What's happening: Stopping an instance is like shutting down a computer properly. It ensures all data is written to disk and no processes are running. You won't be charged for compute time while the instance is stopped, though you'll still pay for any attached storage.

[Screenshot: Instance state dropdown menu with "Stop instance" highlighted]


Creating the AMI

Step 6: Initiate AMI Creation

Now that you have your instance selected (and stopped, if you chose to do so):

  1. With the instance still selected, click the Actions dropdown button at the top

  2. Hover over Image and templates

  3. Click Create image

[Screenshot: Actions menu expanded showing "Image and templates" submenu with "Create image" option]

Step 7: Configure AMI Details

You'll now see the "Create Image" configuration page. This is where you define the properties of your new AMI.

Fill out the following fields:

Image name (required)

  • Enter a descriptive name for your AMI

  • Example: "WebServer-Configured-2024-01-13"

  • Tip: Use a naming convention that includes the purpose and date

Image description (optional but recommended)

  • Add details about what's included in this AMI

  • Example: "Ubuntu 22.04 with Apache, PHP 8.1, and MySQL configured"

  • This helps you remember what the AMI contains when you use it later

[Screenshot: Create Image dialog showing the name and description fields]

Step 8: Review Volume Settings

Scroll down to the Instance volumes section. This shows the storage volumes attached to your instance.

What you're seeing:

  • Each row represents a storage volume (like a hard drive)

  • The volumes will be included in your AMI by default

  • Key columns:

    • Volume type: The type of storage (gp3, gp2, etc.)

    • Device: The device name (/dev/xvda, etc.)

    • Snapshot: Will show "New" indicating a new snapshot will be created

    • Size: The size of the volume in GB

    • Delete on termination: Whether the volume is deleted when an instance is terminated

For most cases, you can leave these settings as they are. The default configuration will create snapshots of all attached volumes and include them in your AMI.

[Screenshot: Instance volumes section of the Create Image dialog]

Step 9: Review and Create

  1. Review all your settings one final time

  2. Ensure the image name is descriptive and correct

  3. Click the Create image button at the bottom right

[Screenshot: Create image button at the bottom of the dialog]

Step 10: Confirm Creation

You should see a success message with your new AMI ID (starting with "ami-").

  1. Note or copy the AMI ID for your records

  2. Click Close or the AMI ID link to view your AMI

What's happening now: AWS is creating snapshots of all the volumes attached to your instance and packaging them into an AMI. This process happens in the background and can take several minutes to complete.

[Screenshot: Success message showing the new AMI ID]


Verifying Your AMI

Step 11: Navigate to the AMIs Page

  1. In the left sidebar, under "Images," click AMIs

  2. You'll see a list of all AMIs available to you

[Screenshot: Left sidebar with AMIs link highlighted under Images section]

Step 12: Check AMI Status

  1. Locate your newly created AMI in the list (you can search by the name you gave it)

  2. Check the Status column

Status meanings:

  • Pending: The AMI is still being created (snapshots are being taken)

  • Available: The AMI is ready to use

  • Failed: Something went wrong (rare)

Note: The creation process typically takes 5-15 minutes depending on the size of your volumes. You can refresh the page to check for status updates.

[Screenshot: AMIs list showing a newly created AMI with "pending" or "available" status]

Step 13: View AMI Details

Once your AMI status shows "Available":

  1. Click on your AMI's checkbox to select it

  2. The details panel at the bottom will show comprehensive information about your AMI:

    • AMI ID

    • Creation date

    • Architecture (x86_64 or ARM)

    • Root device type

    • Virtualization type

    • Block device mappings (storage volumes)

[Screenshot: AMI selected with details panel showing at the bottom]


Using Your New AMI (Optional Verification)

Step 14: Launch an Instance from Your AMI

To verify that your AMI works correctly, you can launch a test instance:

  1. With your AMI selected, click the Launch instance from AMI button at the top

  2. This will take you to the EC2 instance launch wizard with your AMI pre-selected

  3. You can proceed to configure and launch an instance, or click Cancel if you were just verifying

[Screenshot: Launch instance from AMI button highlighted]


Adding your AMI to Vocareum

After validating that the state of your AMI is "available" (see Step 12: Check AMI Status), follow this guide for Registering a VM Lab Image in Vocareum.


Troubleshooting

AMI Creation Failed

  • Check that you have sufficient permissions to create AMIs and snapshots

  • Ensure the source instance is in a valid state

  • Verify that there are no volume attachment issues

AMI Shows "Pending" for a Long Time

  • Large volumes take longer to snapshot (this is normal)

  • If it's been over 30 minutes, check the AWS Service Health Dashboard for any EC2 issues in your region

Cannot Find My AMI

  • Ensure you're in the correct AWS region (check the region selector in the top right)

  • AMIs are region-specific and won't appear if you're viewing a different region

  • Use the search/filter function to find your AMI by name


Best Practices

  1. Naming Convention: Use descriptive, dated names (e.g., "ProductionWeb-v2-2024-01-13")

  2. Documentation: Always fill in the description field with configuration details

  3. Regular Backups: Create AMIs of critical instances on a regular schedule

  4. Tag Your AMIs: Add tags to organize and track AMIs (Owner, Environment, Purpose, etc.)

  5. Cleanup: Delete old, unused AMIs to avoid unnecessary storage costs

  6. Test Your AMIs: Always test launching an instance from a new AMI to verify it works correctly


Additional Resources

Did this answer your question?