0Pricing
AWS Solutions Architect · Lesson

Cost Optimisation and Sustainability Pillars

Adopt expenditure awareness, matched resource sizing, and pricing model selection for cost; minimise infrastructure footprint and improve energy efficiency for sustainability.

Cost Optimisation and Sustainability Pillars is a free AWS Solutions Architect lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Cost Optimisation Pillar Overview

The Cost Optimisation pillar focuses on avoiding unnecessary costs and getting the most value from your AWS spending. It is often the most immediately impactful pillar because cloud resources are easy to over-provision. Key design principles: Implement cloud financial management — treat cost as a first-class metric. Adopt a consumption model — pay only for what you use. Measure overall efficiency — track cost per unit of business value. Reduce spending on undifferentiated heavy lifting — use managed services instead of managing infrastructure.

# Cost Optimisation pillars:
# 1. Expenditure awareness  - visibility into what you spend
# 2. Cost-effective resources - right instance types, storage classes
# 3. Matching supply to demand - auto scaling, spot instances
# 4. Optimising over time - regularly review and adjust

# Example: undifferentiated heavy lifting
# Instead of managing your own Redis: use ElastiCache
# Instead of managing Kubernetes: use EKS or Fargate
# Managed services reduce operational overhead AND cost

Right-Sizing Resources

Right-sizing is the most impactful cost optimisation action — identifying and eliminating over-provisioned resources. A common pattern is launching large instances during initial provisioning and never revisiting them. AWS Compute Optimizer analyses utilisation metrics and recommends the optimal instance type. Common finding: an m5.4xlarge running at 5% CPU should be a t3.medium, saving 80% of compute cost. Right-sizing applies to EC2, Lambda (memory), RDS, and EBS volumes.

# Get Compute Optimizer recommendations for all EC2
aws compute-optimizer get-ec2-instance-recommendations \
  --filters Name=finding,Values=Overprovisioned

# Response includes:
# currentInstanceType: m5.4xlarge
# recommendedInstanceType: t3.large
# estimatedMonthlySavings: $280
# performanceRisk: VeryLow

# Also check EBS volumes:
aws compute-optimizer get-ebs-volume-recommendations \
  --filters Name=finding,Values=Overprovisioned

Purchasing Model Optimisation

For steady-state workloads, On-Demand pricing is the most expensive option. Significant savings are available through: Reserved Instances (1 or 3 years) — up to 72% savings for predictable workloads. Savings Plans — flexible commitment (up to 66% savings) that applies across instance families and regions. Spot Instances — up to 90% savings for interruptible workloads (batch, CI/CD, stateless). A typical cost-optimised fleet combines all three: Savings Plans for the baseline, Spot for burst, On-Demand for edge cases.

# Purchasing model comparison:
# On-Demand:       $0.192/hr (m5.large)   No commitment
# 1yr Reserved:    $0.114/hr              $0.78/hr effective
# 3yr Reserved:    $0.074/hr              Highest savings
# Compute SP:      ~$0.128/hr             Flexible family/region
# Spot:            $0.05-0.08/hr          Interruptible

# Savings Plans cover:
# - Compute Savings Plans: EC2 + Lambda + Fargate
# - EC2 Instance Savings Plans: specific family in one region

Spot Instances for Cost Optimisation

Spot Instances use spare AWS capacity at up to 90% discount but can be interrupted with 2 minutes' notice when AWS needs the capacity back. Spot works well for: batch processing (checkpoint and resume), CI/CD build agents, stateless web servers (behind ALB; ELB routes around interrupted instances), and EMR and EKS worker nodes. Use Spot Fleet or ASG with multiple instance types and AZs to diversify across pools and reduce interruption risk.

# ASG with mixed instances (On-Demand + Spot)
aws autoscaling create-auto-scaling-group \
  --auto-scaling-group-name my-mixed-asg \
  --mixed-instances-policy '{
    "LaunchTemplate": {"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-12345","Version":"$Latest"},"Overrides":[{"InstanceType":"m5.large"},{"InstanceType":"m5a.large"},{"InstanceType":"m4.large"}]},
    "InstancesDistribution": {
      "OnDemandPercentageAboveBaseCapacity": 20,
      "SpotAllocationStrategy": "capacity-optimized"
    }
  }' \
  --min-size 2 --max-size 20 --desired-capacity 5

S3 Storage Cost Optimisation

S3 storage costs can be dramatically reduced by using the right storage class and automating transitions. S3 Intelligent-Tiering automatically moves objects between access tiers based on access patterns — ideal when access patterns are unknown. Lifecycle rules transition objects on a schedule: from Standard → Standard-IA after 30 days → Glacier after 90 days → Deep Archive after 180 days. Also consider S3 Select to retrieve only the needed subset of object data, reducing data transfer and processing costs.

# S3 lifecycle policy for cost optimisation
aws s3api put-bucket-lifecycle-configuration \
  --bucket my-data-bucket \
  --lifecycle-configuration '{
    "Rules": [{
      "ID": "auto-archive",
      "Status": "Enabled",
      "Transitions": [
        {"Days": 30, "StorageClass": "STANDARD_IA"},
        {"Days": 90, "StorageClass": "GLACIER_IR"},
        {"Days": 365, "StorageClass": "DEEP_ARCHIVE"}
      ]
    }]
  }'

Tagging and Cost Allocation

Without proper tagging, it is impossible to understand what each team or project is spending. Cost Allocation Tags let you break down costs by team, project, environment, or any dimension you define. Activate tags in the Billing console, then use AWS Cost Explorer to filter and group costs by tag. Enforce tagging with Tag Policies in AWS Organizations and use AWS Config rules to detect untagged resources. This enables showback (visibility) and chargeback (cost attribution) to individual teams.

# Enforce required tags with Config rule
aws configservice put-config-rule \
  --config-rule '{
    "ConfigRuleName": "required-tags",
    "Source": {"Owner":"AWS","SourceIdentifier":"REQUIRED_TAGS"},
    "InputParameters": "{\"tag1Key\":\"Project\",\"tag2Key\":\"Environment\",\"tag3Key\":\"Owner\"}"
  }'

# Query cost by tag in Cost Explorer
aws ce get-cost-and-usage \
  --time-period Start=2026-06-01,End=2026-06-30 \
  --granularity MONTHLY \
  --group-by Type=TAG,Key=Project

Sustainability Pillar Overview

The Sustainability pillar (added in 2021) focuses on minimising the environmental impact of cloud workloads by reducing energy consumption and increasing efficiency. Design principles: Understand your impact — measure the carbon footprint of your workloads. Establish sustainability goals. Maximise utilisation — right-size to avoid idle resources. Anticipate and adopt more efficient hardware — use the latest instance generations. Use managed services — AWS runs data centres more efficiently than most organisations.

# Sustainability improvement areas:
# 1. Right-size instances (reduce idle energy use)
# 2. Use Graviton (ARM) instances: 60% less energy than x86
# 3. Use Spot instances: uses otherwise idle capacity
# 4. Use managed services: AWS optimises their utilisation
# 5. Use serverless: no idle servers
# 6. Move to S3/EFS instead of EC2 instance storage
# 7. Implement data lifecycle (don't store forever)

AWS Graviton for Sustainability and Cost

AWS Graviton processors (ARM-based) offer up to 60% better energy efficiency and 20-40% better price/performance compared to x86 instances. Graviton3/4 instances (c7g, m7g, r7g, t4g families) are available for most EC2, Lambda, and Fargate workloads. Moving from x86 to Graviton improves both the Sustainability and Cost Optimisation pillars simultaneously — fewer watts per computation and lower instance prices. Most workloads (Linux, containerised apps, JVM) can migrate with minimal changes.

# Compare: m5.large (x86) vs m7g.large (Graviton3)
# m5.large:  $0.096/hr, 2 vCPU, 8 GB
# m7g.large: $0.0808/hr, 2 vCPU, 8 GB
# Savings: ~16% cheaper + 40% better performance

# Switch Lambda function to Graviton (arm64)
aws lambda update-function-configuration \
  --function-name my-function \
  --architectures arm64

# Lambda arm64 is 20% cheaper than x86
# Most Python, Node.js, Java functions work unchanged

Eliminating Idle Resources

A major source of unnecessary cost and energy waste is idle resources — EC2 instances sitting at 1% CPU, unattached EBS volumes, unused Elastic IPs, and forgotten dev/test environments running 24/7. Implement a stop/start schedule for non-production environments using EventBridge rules and Systems Manager Automation — stop dev instances at 6pm, start at 8am. Use AWS Trusted Advisor and Cost Explorer to identify idle instances, unused EBS volumes, and underutilised Reserved Instances.

# EventBridge + SSM to stop dev instances nights/weekends
aws events put-rule \
  --name stop-dev-instances \
  --schedule-expression 'cron(0 22 ? * MON-FRI *)'

aws events put-targets \
  --rule stop-dev-instances \
  --targets '[{
    "Id": "StopDevInstances",
    "Arn": "arn:aws:ssm:us-east-1::automation-definition/AWS-StopEC2Instance",
    "RoleArn": "arn:aws:iam::123:role/EventBridgeRole",
    "Input": "{\"InstanceId\":[\"i-dev1\",\"i-dev2\"]}"
  }]'

Data Lifecycle for Sustainability

Storing data indefinitely wastes energy. The Sustainability pillar recommends implementing data lifecycle policies to automatically delete or archive data that is no longer needed. Use S3 Lifecycle rules with expiration dates to delete objects after a retention period. Use DynamoDB TTL to automatically expire old records. Use CloudWatch Logs retention policies to delete log groups after a defined period. Deleting unnecessary data reduces both your storage costs and the energy required to store and cool it.

# DynamoDB TTL for session data
# Add ttl attribute to items (Unix epoch timestamp)
aws dynamodb update-time-to-live \
  --table-name UserSessions \
  --time-to-live-specification Enabled=true,AttributeName=expiresAt

# Item will be deleted automatically after expiresAt timestamp
# Example: {'userId': 'u1', 'expiresAt': 1750000000}

# CloudWatch Logs: set 30-day retention
aws logs put-retention-policy \
  --log-group-name /aws/lambda/my-function \
  --retention-in-days 30

Cost Optimisation vs Other Pillars

Cost Optimisation sometimes conflicts with other pillars. Multi-AZ RDS doubles your database cost but is required for the Reliability pillar. Cross-Region Replication improves reliability but increases storage and transfer costs. Active-active multi-region reduces latency (Performance Efficiency) but costs 2-3x more. The Well-Architected Framework does not say to always choose the cheapest option — it says to make conscious trade-offs between pillars and document the reasoning. The exam tests your ability to select the most cost-effective solution that still meets the stated requirements.

# Cost vs reliability trade-off example:
# Single-AZ RDS: $100/month, no HA
# Multi-AZ RDS:  $200/month, automated failover

# Decision: if database failure = $10,000/hour of revenue loss
# Even 1 event/year justifies Multi-AZ
# ($10,000 expected loss > $1,200/year extra cost)

# SAA-C03 exam approach:
# Meet the stated requirements FIRST
# Then choose the cheapest option that meets them

Quick Check

Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.

Lesson Recap

In this lesson you learned: Cost Optimisation combines right-sizing, purchasing models (Reserved/Savings Plans/Spot), and S3 lifecycle management, Sustainability focuses on maximising utilisation, using Graviton instances, and implementing data lifecycle policies, and cost trade-offs with other pillars should be made consciously based on business requirements. Cost tags enable showback and chargeback across teams. Next up we explore the Well-Architected Tool and the review process.

Frequently asked questions

Is the “Cost Optimisation and Sustainability Pillars” lesson free?

Yes — the full text of “Cost Optimisation and Sustainability Pillars” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.

What will I learn in “Cost Optimisation and Sustainability Pillars”?

Adopt expenditure awareness, matched resource sizing, and pricing model selection for cost; minimise infrastructure footprint and improve energy efficiency for sustainability. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS Solutions Architect?

No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Cost Optimisation and Sustainability Pillars” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS Solutions Architect lesson?

Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Operational Excellence and Security Pillars
  2. Reliability and Performance Efficiency Pillars
  3. Cost Optimisation and Sustainability Pillars
  4. Well-Architected Tool and Review Process
← Back to AWS Solutions Architect