Hands-On Lab: AWS Cloud Economics & Cost Management
Understand concepts of cloud economics
Hands-On Lab: AWS Cloud Economics & Cost Management
Welcome to this guided hands-On lab on AWS Cloud Economics. One of the primary drivers for migrating to the AWS Cloud is the shift from a fixed capital expense (CapEx) model to a variable operating expense (OpEx) model. In this lab, you will explore real-world cloud economics by rightsizing resources with the AWS Pricing Calculator, deploying tagged resources for cost tracking, and configuring AWS Budgets to prevent cost overruns.
Prerequisites
Before starting this lab, ensure you have the following:
- AWS Account: An active AWS account with Administrator or Billing access.
- AWS CLI: Installed and configured (
aws configure) with valid credentials. - IAM Permissions:
ec2:RunInstances,ec2:TerminateInstances,budgets:ModifyBudget, andbudgets:ViewBudget. - Prior Knowledge: Understanding of basic AWS global infrastructure and the difference between Fixed Costs (CapEx) and Variable Costs (OpEx).
Learning Objectives
By completing this lab, you will be able to:
- Model application costs using the AWS Pricing Calculator.
- Apply Cost Allocation Tags to track project-specific AWS spending.
- Configure AWS Budgets to monitor your variable costs and send automated alerts.
- Understand the practical differences between on-premises CapEx and cloud-based OpEx.
Architecture Overview
The following diagram illustrates the cost management workflow you will build. You will deploy tagged resources, which feed data into the AWS Billing console. AWS Budgets will monitor this data and alert you if you exceed your thresholds.
Step-by-Step Instructions
Step 1: Estimate Costs with the AWS Pricing Calculator
Before deploying resources, it is a cloud economics best practice to estimate your variable costs.
As this is a planning step, there is no CLI equivalent. You will use the web interface.
- Open your web browser and navigate to calculator.aws.
- Click Create estimate.
- Search for Amazon EC2 and click Configure.
- Under EC2 instances, select Shared Instances, Linux OS, and a
t2.microinstance type. - Scroll down to view the Pricing strategy (On-Demand) and the total estimated monthly cost.
📸 Screenshot: Save a screenshot of your estimated monthly bill for your records.
[!TIP] Rightsizing is the process of matching instance types and sizes to your workload performance and capacity requirements at the lowest possible cost. The calculator is your first tool for rightsizing.
Step 2: Deploy a Tagged EC2 Instance
To effectively track your cloud spend across multiple departments or projects, you must use Cost Allocation Tags.
Run the following CLI command to launch a Free-Tier eligible t2.micro instance with a specific Project tag.
aws ec2 run-instances \
--image-id ami-0c55b159cbfafe1f0 \
--count 1 \
--instance-type t2.micro \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Project,Value=CloudEconomics}]'(Note: Replace ami-0c55b159cbfafe1f0 with a valid Amazon Linux 2 AMI ID for your specific region if needed).
▶Console alternative
- Navigate to the EC2 Dashboard.
- Click Launch instances.
- Name the instance
Economics-Lab-Instance. - Select Amazon Linux 2 AMI and
t2.micro. - Under Advanced details > Tags, click Add new tag.
- Key:
Project| Value:CloudEconomics. - Click Launch instance.
Step 3: Configure AWS Budgets
To avoid costly cloud overspends, we will set up an AWS Zero-Spend Budget. This budget will alert you if your account accrues any charges.
First, create a JSON file named budget.json:
{
"BudgetName": "ZeroSpendBudget",
"BudgetLimit": {
"Amount": "1.00",
"Unit": "USD"
},
"CostFilters": {},
"CostTypes": {
"IncludeTax": true,
"IncludeSubscription": true,
"UseBlended": false
},
"TimeUnit": "MONTHLY",
"BudgetType": "COST"
}Next, create a JSON file named notifications.json:
[
{
"Notification": {
"NotificationType": "ACTUAL",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 100,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [
{
"SubscriptionType": "EMAIL",
"Address": "your-email@example.com"
}
]
}
]Now, execute the CLI command to apply the budget:
aws budgets create-budget \
--account-id <YOUR_ACCOUNT_ID> \
--budget file://budget.json \
--notifications-with-subscribers file://notifications.json[!IMPORTANT] Replace
<YOUR_ACCOUNT_ID>with your 12-digit AWS account ID, and updateyour-email@example.comin the JSON file to your actual email address.
▶Console alternative
- Open the AWS Billing Dashboard.
- In the left navigation pane, select Budgets.
- Click Create budget.
- Select Use a template (simplified) and choose Zero spend budget.
- Enter your email address under Email recipients.
- Click Create budget.
Checkpoints
Verify that your resources are correctly deployed and tagged.
1. Verify EC2 Tags:
aws ec2 describe-instances \
--filters "Name=tag:Project,Values=CloudEconomics" \
--query "Reservations[*].Instances[*].[InstanceId, State.Name]" \
--output tableExpected Result: A table displaying your Instance ID and a state of running.
2. Verify AWS Budget:
aws budgets describe-budgets \
--account-id <YOUR_ACCOUNT_ID>Expected Result: A JSON output detailing the ZeroSpendBudget you just created.
Teardown
[!WARNING] Remember to run the teardown commands to avoid ongoing charges. Leaving EC2 instances running will eventually exhaust your Free Tier limits.
Follow these steps to destroy all resources provisioned in this lab.
1. Terminate the EC2 Instance:
aws ec2 terminate-instances --instance-ids <YOUR_INSTANCE_ID>2. Delete the AWS Budget:
aws budgets delete-budget \
--account-id <YOUR_ACCOUNT_ID> \
--budget-name "ZeroSpendBudget"Troubleshooting
| Error Message / Issue | Cause | Fix |
|---|---|---|
UnauthorizedOperation | Your IAM user lacks permissions | Ensure your user has AmazonEC2FullAccess or specific run/terminate permissions attached. |
InvalidAMIID.NotFound | AMI ID does not exist in your region | Find a valid Amazon Linux 2 AMI ID for your current region using the AWS Console and replace it in the CLI command. |
AccessDeniedException (Budgets) | Lack of Billing permissions | Ask your root account administrator to enable IAM user access to the Billing console. |
Cost Estimate
- Amazon EC2 (
t2.micro): $0.00 (Covered entirely by the AWS Free Tier if under 750 hours/month. Otherwise, ~$0.0116/hour). - AWS Budgets: $0.00 (Your first two action-enabled budgets are free).
- Total Estimated Cost: $0.00
Concept Review: CapEx vs. OpEx
Understanding the cloud pricing model requires recognizing the shift in expense types.
Definition-Example Pairs
- Capital Expense (CapEx): Up-front investments for hardware, software, and infrastructure. These are fixed costs that do not scale down if usage drops.
- Real-world example: Buying $50,000 worth of physical servers for a data center. If your application fails and nobody uses the servers, you still spent the $50,000.
- Operating Expense (OpEx): Variable costs based strictly on the resources you consume (pay-as-you-go).
- Real-world example: Paying $15 a month for an AWS EC2 instance. If your application fails, you terminate the instance and stop paying immediately.
- Economies of Scale: The cost advantages that enterprises obtain due to their scale of operation.
- Real-world example: Because AWS buys hardware by the millions, they get massive discounts from manufacturers. They pass these savings to you, meaning your per-unit compute cost is lower than if you bought your own single server.