Hands-On Lab: AWS Cloud Adoption & Elasticity Strategies
Cloud adoption strategies
Hands-On Lab: AWS Cloud Adoption & Elasticity Strategies
Welcome to this guided hands-on lab exploring the practical applications of the AWS Cloud Adoption Framework (CAF) and cloud economics. In this lab, we will simulate migrating a workload, optimizing its cost through rightsizing (adjusting compute power to match demand), and leveraging cloud elasticity to scale our application.
Prerequisites
Before starting this lab, ensure you have the following ready:
- An active AWS Account with administrator access or full EC2 IAM permissions.
- The AWS CLI installed and configured with your credentials (
aws configure). - Basic knowledge of cloud computing concepts (Compute, Storage).
- Terminal application (Bash, PowerShell, or AWS CloudShell).
Learning Objectives
By completing this lab, you will be able to:
- Deploy a compute workload mimicking an initial on-premises migration.
- Apply cloud economics by rightsizing an EC2 instance to minimize fixed costs.
- Demonstrate horizontal scalability and agility by creating and deploying an Amazon Machine Image (AMI).
- Clean up and de-provision resources to adhere to cost-optimization best practices.
Architecture Overview
The following diagram illustrates the lifecycle of our resources in this lab, reflecting the transition from an initial deployment to a cost-optimized, elastic architecture.
The Cloud Transformation Value Chain
As you execute these technical steps, remember how AWS defines the transformation value chain within the Cloud Adoption Framework (CAF):
Step-by-Step Instructions
Step 1: Deploy the Initial "Migrated" Workload
We start by launching an Amazon EC2 instance. This represents an application that has just been lifted-and-shifted to the cloud but hasn't yet been optimized for cloud economics.
aws ec2 run-instances \
--image-id resolve:ssm:/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64 \
--instance-type t2.micro \
--tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=brainybee-lab-migration-node}]"📸 Screenshot: Note the
InstanceIdreturned in the JSON output. You will need it for the next steps.
▶Console alternative
- Navigate to the EC2 Dashboard in the AWS Management Console.
- Click Launch Instances.
- Enter the name:
brainybee-lab-migration-node. - Select Amazon Linux 2023 AMI under Application and OS Images.
- Select t2.micro under Instance type.
- Select Proceed without a key pair (for this lab's scope).
- Click Launch instance.
[!TIP] In a real-world scenario, you would monitor this instance using Amazon CloudWatch to determine if its compute capacity is being fully utilized.
Step 2: Stop the Instance for Rightsizing
One of the core concepts of cloud economics is avoiding over-provisioning. If our application only requires a fraction of a t2.micro, we can rightsize it to a smaller instance type. First, we must stop the instance.
aws ec2 stop-instances --instance-ids <YOUR_INSTANCE_ID>▶Console alternative
- In the EC2 Dashboard, select your instance
brainybee-lab-migration-node. - Click the Instance state dropdown.
- Select Stop instance.
- Wait until the Instance State changes to
stopped.
Step 3: Rightsize the Instance
Now, we modify the instance type to a t2.nano, successfully demonstrating variable cost optimization and "rightsizing."
aws ec2 modify-instance-attribute \
--instance-id <YOUR_INSTANCE_ID> \
--instance-type "{\"Value\": \"t2.nano\"}"After modifying, start the instance back up:
aws ec2 start-instances --instance-ids <YOUR_INSTANCE_ID>▶Console alternative
- With the stopped instance selected, click Actions > Instance settings > Change instance type.
- In the dropdown, select t2.nano.
- Click Apply.
- Go back to Instance state and click Start instance.
Step 4: Create an Amazon Machine Image (AMI)
To prepare for high availability and agility, we will capture our optimized server configuration as an AMI. This is a foundational step for implementing elasticity (e.g., via Auto Scaling).
aws ec2 create-image \
--instance-id <YOUR_INSTANCE_ID> \
--name "brainybee-optimized-ami" \
--description "Optimized baseline image for migration lab"📸 Screenshot: Copy the
ImageIdreturned by the command.
▶Console alternative
- Select your running instance.
- Click Actions > Image and templates > Create image.
- Set Image name to
brainybee-optimized-ami. - Click Create image.
- Navigate to AMIs on the left menu and wait for the status to become
Available.
Step 5: Test Agility by Launching from the AMI
Finally, we launch a brand new instance from our custom AMI. This proves that we can rapidly replicate our infrastructure on demand.
aws ec2 run-instances \
--image-id <YOUR_AMI_ID> \
--instance-type t2.nano \
--tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=brainybee-scaled-node}]"▶Console alternative
- Navigate to AMIs in the left navigation pane.
- Select your
brainybee-optimized-ami. - Click Launch instance from AMI.
- Name it
brainybee-scaled-node. - Click Launch instance.
Checkpoints
Run these commands to verify your progress:
-
Verify Instance Types: Check that you have two instances running, both properly rightsized to
t2.nano.bashaws ec2 describe-instances --query "Reservations[*].Instances[*].{ID:InstanceId, Type:InstanceType, State:State.Name}" --output tableExpected Result: Both instances show
t2.nanoand staterunning. -
Verify AMI Availability:
bashaws ec2 describe-images --owners self --query "Images[*].{ID:ImageId, Name:Name, State:State}" --output tableExpected Result: Your custom AMI shows a state of
available.
Teardown / Clean-Up
[!WARNING] Remember to run the teardown commands to avoid ongoing charges. Failing to delete instances and snapshots will incur monthly storage and compute fees.
Run the following commands to destroy the lab environment:
-
Terminate all lab instances:
bashaws ec2 terminate-instances --instance-ids <INSTANCE_ID_1> <INSTANCE_ID_2> -
Deregister the custom AMI:
bashaws ec2 deregister-image --image-id <YOUR_AMI_ID> -
Delete the underlying EBS Snapshot (Crucial to stop storage costs): First, find the Snapshot ID:
bashaws ec2 describe-snapshots --owner-ids self --query "Snapshots[*].SnapshotId"Then, delete it:
bashaws ec2 delete-snapshot --snapshot-id <YOUR_SNAPSHOT_ID>
Troubleshooting
| Error / Issue | Cause | Fix |
|---|---|---|
UnauthorizedOperation | Your IAM user lacks ec2:* permissions. | Attach the AmazonEC2FullAccess policy to your IAM user. |
IncorrectInstanceState | You tried to modify an instance that is still running. | Ensure the instance is completely stopped before rightsizing. |
InvalidAMIID.NotFound | The AMI ID entered does not exist or hasn't finished creating. | Check the AMI status and ensure you pasted the correct ami-xxxx string. |
| AMI creation seems stuck | Snapshot generation can take 2-5 minutes. | Wait a few moments and run the checkpoint command again to verify status. |
Concept Review
This lab practically applied core AWS Cloud Adoption Framework and Economics principles:
| Concept | How We Applied It In Lab |
|---|---|
| Variable vs Fixed Costs | We didn't buy a server; we paid for compute by the second, allowing us to turn it off and change it freely. |
| Rightsizing | We identified that t2.micro was too large and stepped down to t2.nano to slash compute costs. |
| Agility & Speed of Deployment | We stood up a fully configured secondary server in seconds using an AMI. |
| Elasticity | We proved we could rapidly scale out our infrastructure horizontally by launching copies of our base image. |