DEV Community

Cover image for DEV Track Spotlight: Optimize AWS Costs: Developer Tools and Techniques (DEV318)
Gunnar Grosch for AWS

Posted on

DEV Track Spotlight: Optimize AWS Costs: Developer Tools and Techniques (DEV318)

As cloud applications grow in complexity, optimizing costs becomes crucial for developers. In this session from AWS re:Invent 2025, Steph Gooch (Senior Solution Architect Advocate at AWS) and Kenneth Attard (AWS Community Hero and Enterprise Architect at Betsson Group) explored AWS-native tools and coding practices that reduce expenses without compromising performance or scalability.

Watch the Full Session:

The Friday Morning Budget Alert

Steph opened with a scenario every developer dreads: "Imagine this, it's Friday morning, you've had an easy week and you expect to sail through the day. And then you get this email, your AWS budget has gone off and it's gone to you, it's gone to your manager, it's gone to your FinOps team and everyone's asking what happens?"

The session's goal was clear: ensure you never receive that email by implementing proactive cost optimization strategies, leveraging AI tools, and preventing future waste.

Simple Optimizations: The Foundation

Kenneth shared real-world optimizations from Betsson Group, one of the leading gaming companies operating in 24 markets. Starting with a target of $100K in savings, he walked through foundational optimizations:

CloudTrail Consolidation: Multiple CloudTrail trails across accounts were generating unnecessary costs. By implementing an organization trail and deleting extra trails, Betsson eliminated redundant logging costs.

EBS Volume Cleanup: Unattached EBS volumes were accumulating costs. The solution was straightforward: delete unused volumes and take backups only when needed for compliance.

Networking Optimization: Public-facing Elastic Load Balancers were generating double costs (public IPs plus load balancer charges). Extra NAT gateways and transit gateways were also identified and removed where unnecessary.

Right-Sizing with Graviton: Kenneth emphasized the impact of moving to AWS Graviton processors: "Graviton is an ARM based CPU that AWS developed and it's very cost efficient both from a cost and also from a performance perspective." This applied not just to EC2 instances, but also to RDS databases and Lambda functions.

Storage Optimization: For Amazon S3, Betsson implemented intelligent tiering and moved infrequently accessed data to Amazon S3 Glacier. For databases, migrating from Intel-based instances to Graviton-based RDS instances provided both cost savings and performance improvements.

Leveraging AI for Cost Optimization

Steph demonstrated how AI tools can accelerate the optimization journey, focusing on Amazon Q Developer and Kiro CLI.

AWS Cost Optimization Hub

Cost Optimization Hub provides a single pane of glass for optimization opportunities. Steph showed how it categorizes savings by action type, account, region, and resource type, giving a realistic view of achievable savings rather than inflated estimates.

The hub integrates with AWS Compute Optimizer to provide detailed recommendations with supporting data, helping developers make informed decisions about right-sizing and migration opportunities.

Amazon Q Developer and Kiro CLI with MCPs

Model Context Protocol (MCP) servers enable AI assistants to connect directly to AWS services. Steph demonstrated using Kiro CLI with MCPs to:

  1. Query Cost Optimization Hub for compute recommendations
  2. Identify specific resources to optimize
  3. Automatically update infrastructure code (CloudFormation templates)
  4. Generate and execute AWS CLI commands for deployment

The key insight: "The time it takes to log into the console and see all of your savings in Cost Optimization Hub is very similar to using Kiro, finding the recommendation and making the change." AI tools don't just identify savings, they help implement them faster.

Infrastructure Optimization with Amazon Q

Amazon Q Developer includes a built-in optimization feature. By selecting infrastructure code and choosing "optimize," developers receive recommendations across three dimensions:

  • Cost: Identifying expensive resources and suggesting alternatives
  • Architecture: Improving design patterns and service selection
  • Security: Highlighting potential vulnerabilities

In the demo, Amazon Q analyzed a CloudFormation template and identified significant cost savings opportunities, providing both the analysis and updated code.

Advanced Optimizations: Deep Dives

Amazon CloudWatch Logs Optimization

Kenneth shared multiple strategies for reducing Amazon CloudWatch costs:

  • Delete unnecessary log groups and data
  • Set appropriate retention periods instead of "never expires"
  • Optimize application code to reduce log volume
  • Implement CloudWatch Logs Infrequent Access for logs that don't require frequent querying

AWS Config Optimization

For Amazon EKS clusters with auto-scaling, continuous AWS Config recording generated excessive costs. "We had Config enabled on EKS... EKS was configured for continuous. So in busy periods when there's a good game, EKS start doing auto scaling. So it was recording a lot of changes." Switching from continuous to daily recording dramatically reduced costs.

Data Transfer Optimization

Data transfer charges can accumulate quickly. Betsson implemented several strategies:

Amazon S3 Gateway Endpoints: "There's a good free feature that AWS offers. Yes, you heard it right, it's free. Which are the S3 gateway endpoints." By implementing gateway endpoints, S3 traffic stayed within the AWS network instead of routing through NAT gateways, eliminating data transfer charges.

Cross-AZ Traffic Reduction: Deploying NAT gateways in each availability zone prevented cross-AZ traffic charges. Kubernetes was also configured to keep traffic within the same availability zone when possible.

Network ACLs: Blocking unwanted traffic at the subnet level with Network ACLs prevented unnecessary data processing charges across AWS networking components.

AWS Lambda Optimization

AWS Lambda cost optimization focused on three areas:

  1. Graviton Migration: Moving Lambda functions to ARM-based Graviton processors
  2. Right-Sizing: Reducing compute requirements after architecture changes
  3. Code Optimization: Reducing function complexity and execution time

Centralized NAT Gateway Architecture

Kenneth presented an advanced networking optimization: centralizing NAT gateways in a dedicated egress VPC connected via AWS Transit Gateway.

The math was compelling. For three VPCs with NAT gateways processing 2TB of data:

  • Traditional setup: $190/month (3 NAT gateways)
  • Centralized setup: $322/month (3 NAT gateways + Transit Gateway attachments + processing)

Wait, that's more expensive? Kenneth explained: "That is the cost savings, but it doesn't apply for small setups." The breakeven point is 10 VPCs. Beyond that, savings scale up to 8% as more VPCs are added.

The key optimizations that made this work:

  • Amazon S3 gateway endpoints reducing traffic by 38.5-45%
  • Network ACLs blocking traffic at the source
  • Centralized management and monitoring

Regional Cost Optimization

Choosing the right AWS region can significantly impact costs. Kenneth shared a Database Migration Service (DMS) example:

For a six.xlarge DMS instance transferring data from Europe to São Paulo:

  • Frankfurt (eu-central-1): $2,573/month
  • Ireland (eu-west-1): $2,300/month
  • N. Virginia (us-east-1): $1,619/month
  • São Paulo (sa-east-1): $4,057/month

By deploying the DMS instance in N. Virginia instead of São Paulo, Betsson saved $2,438 per month. This principle applies to other services where regional pricing varies significantly.

AWS WAF Cost Optimization

AWS WAF has both standard and premium features, with dramatically different pricing models.

Standard Features (included in base price):

  • Geoblocking rules
  • Core rule sets
  • Rate limiting rules
  • IP reputation lists

Premium Features (significantly more expensive):

  • Bot Control
  • Account Creation Fraud Prevention
  • Account Takeover Prevention

Kenneth's advice: "Use as much as possible the standard features like geoblocking rules, like default rules, like core rule sets, rate limiting rules, allow lists, block lists, IP reputation to minimize the traffic that is going to hit the premium features."

CAPTCHA vs. Challenge: CAPTCHA costs $4 per 10,000 requests, while silent Challenge checks cost $0.40 per million responses. Unless user interaction is required, Challenge provides massive savings.

Web ACL Capacity Units: The standard allocation is 1,500 WCUs. By combining Amazon CloudFront with WAF and then routing to an Application Load Balancer or API Gateway (also with WAF), you effectively get 3,000 WCUs (1,500 + 1,500) instead of paying for additional capacity.

Preventing Future Waste

Service Control Policies (SCPs)

Steph introduced Service Control Policies as preventative guardrails: "They are a really good way of preventing potential waste before you even deploy into the cloud."

SCPs set at the organization or OU level can prevent costly mistakes:

Instance Type Restrictions: Prevent deployment of expensive instance types (like 24xlarge or metal) in development accounts while allowing bypass roles for legitimate use cases.

Storage Defaults: Enforce Amazon EBS gp3 volumes (20% cheaper than gp2) as the default for resources up to 1TB.

NAT Gateway Controls: In centralized NAT gateway architectures, prevent users from creating NAT gateways in individual accounts.

Required Tagging: Ensure resources have tags needed for scheduling, automation, security, and compliance before deployment.

Graviton Enforcement: Default to Graviton-based instance types for managed services, providing 10% savings automatically.

Region Restrictions: Prevent accidental deployment in expensive or unintended regions.

Steph demonstrated using Kiro CLI to create SCPs and test infrastructure code against them before deployment, providing the benefits of SCPs without immediately enforcing them in production.

Context: Teaching AI Your Preferences

Both Amazon Q Developer and Kiro CLI support context files that store information about your preferences, projects, and best practices.

Steph demonstrated creating a rule in Amazon Q Developer specifying that Lambda functions should:

  • Use Graviton (ARM64 architecture)
  • Always include a CloudWatch log group
  • Set appropriate retention policies

With this context configured, simply asking to "create a simple test CloudFormation for Lambda" automatically generated optimized code following these preferences.

In Kiro CLI, context files work similarly. Using context add\ to specify a file with optimization preferences ensures all generated infrastructure follows cost optimization best practices from the start.

Steph's advice: "If you ever find yourself repeating conversations with AI, these are really handy to have."

Key Takeaways

Work Smarter, Not Harder: Use AI tools like Amazon Q Developer and Kiro CLI with MCPs to accelerate optimization implementation.

Optimize the Low-Hanging Fruit Forever: Don't just make one-time optimizations. Use Service Control Policies and context files to ensure best practices are followed automatically.

Save Time with COMs: Context, Optimize, MCPs, and Save. These four elements create a sustainable cost optimization practice.

Start Small: Kenneth and Steph encouraged attendees to choose one optimization from the session and implement it. Small wins build momentum for larger optimization initiatives.

Data Drives Decisions: Use tools like AWS Cost Optimization Hub and AWS Compute Optimizer to understand the data behind recommendations before implementing changes.

The Ultimate Goal

Steph concluded with the vision: "I want you to succeed. I want you to save all this money and I want you to reinvest it. I want you to reinvest it into new staff, into new certificates, into new resources, new features of your applications, whatever is gonna make your business better."

Cost optimization isn't about cutting corners. It's about eliminating waste so you can invest in innovation, growth, and delivering value to customers.


About This Series

This post is part of DEV Track Spotlight, a series highlighting the incredible sessions from the AWS re:Invent 2025 Developer Community (DEV) track.

The DEV track featured 60 unique sessions delivered by 93 speakers from the AWS Community - including AWS Heroes, AWS Community Builders, and AWS User Group Leaders - alongside speakers from AWS and Amazon. These sessions covered cutting-edge topics including:

  • 🤖 GenAI & Agentic AI - Multi-agent systems, Strands Agents SDK, Amazon Bedrock
  • 🛠️ Developer Tools - Kiro, Kiro CLI, Amazon Q Developer, AI-driven development
  • 🔒 Security - AI agent security, container security, automated remediation
  • 🏗️ Infrastructure - Serverless, containers, edge computing, observability
  • Modernization - Legacy app transformation, CI/CD, feature flags
  • 📊 Data - Amazon Aurora DSQL, real-time processing, vector databases

Each post in this series dives deep into one session, sharing key insights, practical takeaways, and links to the full recordings. Whether you attended re:Invent or are catching up remotely, these sessions represent the best of our developer community sharing real code, real demos, and real learnings.

Follow along as we spotlight these amazing sessions and celebrate the speakers who made the DEV track what it was!

Top comments (0)