Hi, I'm Kazuho. Last week I was named an AWS DevTools Hero in Japan. Most of my community work goes into contributing to the AWS CDK, and I also maintain a few small tools around it. This post is about one of them.
You deploy a CDK app the usual way, nothing unusual in the code, and then the bill shows a few hundred dollars a month for resources you never meant to create. Has that happened to you?
NAT Gateways, load balancers, databases and VPC endpoints charge by the hour whether anyone calls them or not. And it's easy to create one without meaning to. A bare new ec2.Vpc() quietly adds a NAT Gateway in every Availability Zone it uses, and it's common to notice only when the bill arrives.
I wanted to know what a CDK app costs before deploying it, so I wrote cdk-idle-cost. It reads cdk.out and prints what the app costs at zero traffic.
Here it is on a small app with a default VPC, a Multi-AZ Postgres and a Fargate service behind an ALB:
$ cdk synth
$ npx cdk-idle-cost --suggest
us-east-1 · 1 stack · idle ≈ $536/mo
AppStack $536/mo
Db ×1 $365 db.r5.large postgres Multi-AZ
→ -$36/mo: db.r6g.large (Graviton)
Db ×100 GB gp2 $23 storage
→ -$194/mo: Single-AZ instance and storage, for development stacks: no standby, so an AZ failure or maintenance takes the database down
Api/Service/Service ×1 vCPU $30 Fargate vCPU (2 tasks)
→ -$7.21/mo: ARM64 vCPU and memory (Graviton, RuntimePlatform CpuArchitecture), if the image is built for arm64
Api/Service/Service ×2 GB $6.49 Fargate memory (2 tasks)
Vpc/PublicSubnet1/NATGateway ×1 $33 NAT Gateway
Vpc/PublicSubnet2/NATGateway ×1 $33 NAT Gateway
→ -$36/mo: one NAT Gateway for the VPC instead of 2 (CDK natGateways: 1); egress then depends on one AZ
Api/LB ×1 $16 Application Load Balancer
...
→ 5 suggestions save $282/mo
prices: bundled snapshot 2026-11-16 · on-demand list prices, 730 h/mo, USD, free tier ignored
Each line shows the construct path, so you can tell which code to change. --suggest adds cheaper settings along with what each one gives up. One NAT Gateway is fine for dev, less so for production.
How it works
Prices come from a snapshot of the AWS price list that ships with the package, so it runs offline and doesn't need AWS credentials. It knows about 70+ resource types. Usage-based charges like requests and data transfer are left out on purpose, so think of the number as the floor of your bill. If it can't read a value from the template, it doesn't guess. The resource shows up as "could not estimate" with the reason. Plain CloudFormation templates work too, which is why the repository and the original npm package are named cfn-idle-cost. cdk-idle-cost is the same tool under a CDK-friendly name.
In pull requests
--base compares two synthesized apps and shows only what changed. Say a pull request moves the database from db.t4g.medium to db.r5.large, drops natGateways: 1 and adds an interface endpoint:
$ npx cdk-idle-cost --base cdk.out.main cdk.out
us-east-1 · idle ≈ $214 → $536/mo (+$322)
~ AppStack Db $117 → $388 +$271 db.t4g.medium postgres Multi-AZ + 1 more → db.r5.large postgres Multi-AZ + 1 more
+ AppStack Vpc/PublicSubnet2/NATGateway $0.00 → $33 +$33 NAT Gateway
+ AppStack Vpc/SecretsEndpoint $0.00 → $15 +$15 interface endpoint
+ AppStack Vpc/PublicSubnet2/EIP $0.00 → $3.65 +$3.65 public IPv4 address
There's a GitHub Action that posts this as a PR comment and fails the check when the increase goes over max-increase. If you'd rather catch it at cdk synth, IdleCost.apply(app, { max: 300 }) from the cfn-idle-cost package does that.
To try it:
cdk synth
npx cdk-idle-cost
If a price looks off or a resource you use isn't counted, please open an issue.
And if you find it useful, a star on GitHub would make my day.

Top comments (0)