Amazon Elastic Compute Cloud (EC2)
EC2 Real Life Problems and Solutions
Mandatory best practice
Managing large-scale EC2 fleets demands clear identification, cost visibility, and automation. In this guide, we’ll show how Acme Corporation’s engineer Alex standardizes tagging to meet application, finance, and business needs.
Challenges Faced by Alex
- Autoscaling clouds the exact count of running instances per application.
- Hundreds of servers make resource pinpointing difficult.
- Finance needs accurate cost attribution; application teams need performance metrics.
AWS supports up to 50 key–value tags per resource. You can filter and manage these tags via the AWS CLI, SDKs, or the console for services like CloudWatch and Cost Explorer.
Key Benefits of Tagging
- Track server utilization metrics in real time.
- Generate chargeback reports by application.
- Automate workflows (start/stop schedules).
- Filter metrics in CloudWatch and costs in Cost Explorer.
Defining a Consistent Tagging Strategy
To ensure organization-wide consistency, Alex establishes a set of standard tags and expands them with service-specific keys.
Tag Key | Purpose |
---|---|
name | Resource identifier (e.g., web-service ) |
environment | prod , staging , non-prod |
team | Owning team (e.g., alpha ) |
service | Application or service name (e.g., login ) |
business_unit | Business unit (e.g., customer_support ) |
owner | Resource owner or contact email |
Note
Adjust tag values to match your naming conventions and compliance requirements.
Service-Specific Tags
For EC2 instances that should start and stop automatically, Alex adds:
start_time
– Desired start hour (24-hour format)stop_time
– Desired stop hour
A Lambda function leverages these tags to schedule instance state changes.
Additional tags can be added based on new services or evolving business needs.
Implementing the Strategy at Acme Corporation
- Apply Default Tags
All AWS resources receive the six standard tags. - Add Service-Specific Tags
EC2 instances includestart_time
/stop_time
for automated scheduling. - Configure Monitoring
In CloudWatch, filter metrics by theservice
tag to satisfy application teams. - Enable Cost Reporting
In Cost Explorer, filter bybusiness_unit
andenvironment
to deliver finance chargebacks. - Set Budget Alerts
Create budget alarms (e.g., at 80% spend) using cost and application-specific tags so teams act before overages. - Automate Cost Savings
Stop non-production instances outside business hours to cut compute costs by up to 50%.
Example tags for a non-production web service:
# Default Tags
name = web-service
environment = non-prod
team = alpha
service = login
business_unit = customer_support
owner = alex
# EC2 Service-Specific Tags
start_time = 08:00
stop_time = 20:00
Warning
Inconsistent tagging can lead to gaps in automation and cost reporting. Enforce tag policies with AWS Organizations or Service Catalog.
References
- AWS Tagging Strategies
- Tagging Your Amazon EC2 Resources
- AWS CLI: ec2 create-tags
- Amazon CloudWatch User Guide
- AWS Cost Explorer API Reference
Watch Video
Watch video content