Categories
Articles

AWS – Cost breakdown

🧾 Overview of Cost Considerations by Service

1. DynamoDB

  • šŸ’”Ā On-demand vs provisioned:
    • ProvisionedĀ is cheaper if access is predictable. UseĀ Auto ScalingĀ if uncertain.
  • šŸ”Ā Avoid hot partitions: Distribute access evenly using good partition key design.
  • ā³Ā Enable TTL (Time To Live): Automatically delete stale data.
  • šŸ’¾Ā Use DAX or cachingĀ (e.g., with Amplify or Lambda) to reduce reads.
  • šŸ“¦Ā Watch storage: Monitor size growth. Large payloads = large bills.
  • 🧹 Clean up unused tablesĀ in non-prod environments.

2. AWS Amplify

  • šŸ’”Ā Use only necessary Amplify features:
    Hosting, auth, storage, GraphQL APIs can rack up costs—disable unused categories.
  • šŸ’øĀ Hosting costs scale with usage + storage.
    Optimize asset size and invalidate old builds.
  • šŸ”Ā Avoid redeploying often, especially for small changes.
  • šŸ”’Ā Use environment-specific backends, but clean up unused ones.

3. Lambda

  • ā±Ā Keep functions fast: You’re billed for time * RAM.
  • šŸ“¦Ā Minimize memory allocation: 128MB is cheap, 512MB+ adds up fast.
  • 🧪 Use Lambda Power TuningĀ to find optimal memory/runtime balance.
  • āš ļøĀ Avoid recursive callsĀ or poorly terminated functions.
  • 🧹 Delete unused versionsĀ andĀ clean up layers.

4. CloudFormation

  • šŸ“‹Ā Free itself, but canĀ create cost-incurring resources.
  • šŸ›‘ Be careful with templates that create high-tier instances/services by default.
  • 🧹 Remove old stacks/environmentsĀ in test/dev.

5. CloudWatch

  • šŸ“ŠĀ Logs and metrics cost money!Ā Especially retention.
    • KeepĀ short log retentionĀ for dev/test (e.g., 3 days).
    • SetĀ log filtersĀ selectively (don’t log everything).
  • 🧽 UseĀ aws logs delete-log-groupĀ to clean up unused logs.
  • šŸ’” Consider exporting logs to S3 and deleting from CW if needed long-term.

6. API Gateway

  • šŸ’øĀ REST APIs are more expensiveĀ than HTTP APIs.
    • UseĀ HTTP APIsĀ when you don’t need advanced features (e.g. authorizers, WAF).
  • 🧪 UseĀ usage plans + throttling + quotas.
  • šŸ”’Ā Enable cachingĀ to reduce Lambda invocations.

7. IAM

  • šŸ‘€ No direct cost, but indirect:
    • EnsureĀ least privilege: Accidental access to high-cost resources can spike bills.
    • Monitor role usage (some features are billable).

šŸ” General Recommendations

šŸ”” 1. Set Budgets and Alerts

  • UseĀ AWS BudgetsĀ andĀ Cost Anomaly Detection.
  • EnableĀ notifications on spikesĀ in Lambda invocations, API calls, storage usage, etc.

šŸ“¦ 2. Tag All Resources

  • Use cost allocation tags likeĀ env,Ā team,Ā project.
  • Group by environment to isolate cost-heavy dev or test setups.

šŸŒ 3. Minimize Environments

  • Don’t keep too many dev/test environments running 24/7.
  • Automate teardown and re-creation when possible.

🧠 4. Use Savings Plans or Reserved Instances

  • If you have predictable Lambda/Compute usage.

šŸ“ˆ 5. Monitor with Cost Explorer

  • Check cost per service, daily granularity.
  • EnableĀ Resource-level tracking.

āœ… Pro Tips

GoalStrategy
Reduce Lambda costOptimize memory + runtime, use async when possible
Reduce API Gateway costSwitch to HTTP APIs, enable caching, combine endpoints
Reduce DynamoDB costProvisioned capacity + Auto Scaling, optimize reads/writes
Reduce Amplify costHost only necessary features, minimize build frequency
Reduce CloudWatch costShorten log retention, remove unnecessary metrics/logs
General cleanupAutomate stack/resource teardown in dev, especially Amplify environments