Interview Prep/AWS/CloudFormation, CloudWatch, KMS, Secrets and Cost

All dev instances are stopped every night, yet the account still costs money each day.

BeginnerTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer

Likely causes → Stopped instances still have charged EBS volumes. Other charges continue too: snapshots, Elastic IPs and all public IPv4 addresses (charged hourly since February 2024), NAT gateways, load balancers, RDS instances (which also restart automatically after 7 days stopped) and CloudWatch Logs storage.

Diagnose →

aws ec2 describe-volumes --filters Name=status,Values=available --query 'Volumes[].[VolumeId,Size,CreateTime]'
aws ec2 describe-addresses --query 'Addresses[?AssociationId==null].[PublicIp,AllocationId]'
aws ec2 describe-nat-gateways --filter Name=state,Values=available --query 'NatGateways[].NatGatewayId'
aws elbv2 describe-load-balancers --query 'LoadBalancers[].LoadBalancerName'

Fix →

  1. Delete unattached volumes and unused EIPs
  2. Expire old snapshots with Data Lifecycle Manager
  3. Remove idle NATs and ALBs in dev (recreate them with IaC when needed)

Prevent → Run ephemeral dev environments from IaC that are destroyed nightly, and use Trusted Advisor or Compute Optimizer idle-resource checks.

aws All AWS questions Roadmap: Cloud cost & architecture

More on CloudFormation, CloudWatch, KMS, Secrets and Cost