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.

The image is a diagram illustrating AWS Tagging, showing how AWS CLI and AWS API interact with tags like "app = backend" and "app = frontend" for services like CloudWatch and AWS Billing.

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 KeyPurpose
nameResource identifier (e.g., web-service)
environmentprod, staging, non-prod
teamOwning team (e.g., alpha)
serviceApplication or service name (e.g., login)
business_unitBusiness unit (e.g., customer_support)
ownerResource 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.

The image outlines AWS tagging standards, including default tags like name and environment, and service-specific tags for EC2 and Lambda.

Additional tags can be added based on new services or evolving business needs.


Implementing the Strategy at Acme Corporation

  1. Apply Default Tags
    All AWS resources receive the six standard tags.
  2. Add Service-Specific Tags
    EC2 instances include start_time/stop_time for automated scheduling.
  3. Configure Monitoring
    In CloudWatch, filter metrics by the service tag to satisfy application teams.
  4. Enable Cost Reporting
    In Cost Explorer, filter by business_unit and environment to deliver finance chargebacks.
  5. Set Budget Alerts
    Create budget alarms (e.g., at 80% spend) using cost and application-specific tags so teams act before overages.
  6. 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

Watch Video

Watch video content

Previous
Immutable vs non immutable