Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Resource tagging for cost tracking
📖 Scenario: You work in a company that uses AWS cloud services. To keep track of costs, your team wants to tag resources with specific labels. These tags help identify which department or project owns each resource.For this project, you will create AWS EC2 instances with tags that specify the Department and Project. This will help the finance team track spending accurately.
🎯 Goal: Create an AWS CloudFormation template that launches an EC2 instance with the exact tags Department: Finance and Project: Budget2024. This template will be used to deploy tagged resources for cost tracking.
📋 What You'll Learn
Create a CloudFormation template with an EC2 instance resource
Add a parameter for the EC2 instance type
Add tags Department with value Finance and Project with value Budget2024 to the EC2 instance
Use best practices for CloudFormation syntax and structure
💡 Why This Matters
🌍 Real World
Tagging AWS resources helps companies track costs by department or project, making budgeting and billing clearer.
💼 Career
Cloud architects and engineers often create templates with tags to organize resources and enable cost allocation reports.
Progress0 / 4 steps
1
Create the basic CloudFormation template with EC2 instance
Create a CloudFormation template with a resource named MyEC2Instance of type AWS::EC2::Instance. Set the InstanceType property to t2.micro and use the Amazon Linux 2 AMI ID ami-0c55b159cbfafe1f0 for ImageId.
AWS
Hint
Start with the Resources section. Define MyEC2Instance with the correct type and properties.
2
Add a parameter for the EC2 instance type
Add a Parameters section with a parameter named InstanceTypeParam. Set its type to String and default value to t2.micro. Then update the InstanceType property of MyEC2Instance to use this parameter with !Ref InstanceTypeParam.
AWS
Hint
Define the parameter at the top level. Use !Ref InstanceTypeParam to refer to it in the instance properties.
3
Add tags for Department and Project to the EC2 instance
Add a Tags property under MyEC2Instance with two tags: one with Key as Department and Value as Finance, and another with Key as Project and Value as Budget2024.
AWS
Hint
Tags are a list of key-value pairs under the Tags property.
4
Add Outputs section with the EC2 instance ID
Add an Outputs section with an output named InstanceId. Set its Value to !Ref MyEC2Instance and add a Description of EC2 Instance ID.
AWS
Hint
The Outputs section helps you see important information after deployment.
Practice
(1/5)
1. What is the main purpose of adding tags to AWS resources for cost tracking?
easy
A. To organize and identify resources for cost allocation
B. To increase the storage capacity of resources
C. To improve the speed of resource deployment
D. To automatically back up resources daily
Solution
Step 1: Understand the role of tags in AWS
Tags are labels that help organize resources by adding key-value pairs.
Step 2: Connect tags to cost tracking
Tags allow grouping resources to see costs clearly in reports.
Final Answer:
To organize and identify resources for cost allocation -> Option A
Quick Check:
Tags help track costs [OK]
Hint: Tags label resources to track costs easily [OK]
Common Mistakes:
Thinking tags increase storage or speed
Confusing tags with backups
Assuming tags change resource performance
2. Which of the following is the correct syntax to add a tag with key Environment and value Production to an AWS EC2 instance using AWS CLI?
easy
A. aws ec2 tag-instance --id i-1234567890abcdef0 --key Environment --value Production
B. aws ec2 create-tags --resources i-1234567890abcdef0 --tags Key=Environment,Value=Production
C. aws ec2 add-tag --instance i-1234567890abcdef0 --tag Environment=Production
D. aws ec2 set-tags --resource i-1234567890abcdef0 --tags Environment:Production
Solution
Step 1: Recall AWS CLI command for tagging
The correct command is aws ec2 create-tags with resource ID and tags specified as Key=Value pairs.
D. The --tags parameter is missing the required JSON format
Solution
Step 1: Check S3 tagging command syntax
The put-bucket-tagging command requires tags in JSON format under the --tagging parameter, not --tags.
Step 2: Identify the error cause
Using --tags with Key=Value string causes syntax error; correct usage is JSON with --tagging.
Final Answer:
The --tags parameter is missing the required JSON format -> Option D
Quick Check:
S3 tagging needs JSON format [OK]
Hint: Use JSON format with --tagging for S3 bucket tags [OK]
Common Mistakes:
Using --tags instead of --tagging with JSON
Assuming only root user can tag buckets
Believing S3 buckets cannot be tagged
5. You want to track costs for multiple projects in your AWS account. Which tagging strategy will give the clearest cost reports?
hard
A. Tag only the resources with the highest cost
B. Use different tag keys like Project1, Project2 for each project
C. Use a single tag key Project with unique values for each project on all resources
D. Use tags only on EC2 instances, ignoring other resources
Solution
Step 1: Understand best practice for cost tracking tags
Using one consistent tag key with different values groups costs clearly by that key.
Step 2: Evaluate options for clarity
Use a single tag key Project with unique values for each project on all resources uses a single key Project with unique values, making reports easy to filter and compare.
Final Answer:
Use a single tag key Project with unique values for each project on all resources -> Option C
Quick Check:
Consistent tag keys for clear cost reports [OK]
Hint: Use one tag key with different values for projects [OK]