aws / aws/aws-cdk

(ECS): VPC by default created with NAT

Open
#18,720 12 comments 17 reactions 0 assignees View on GitHub
@aws-cdk/aws-ecs documentation effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### link to reference doc page

https://docs.aws.amazon.com/cdk/v2/guide/ecs_example.html

### Describe your issue?

Folks, you are doing a great job. I really enjoy CDK and the direction it takes. I've been using CDK quite happily for building my app using Fargate until I noticed that my AWS bill was ~90$ instead of the expected ~8$ for this project. I started digging into it, and it was NAT Gateway created by CDK when I deployed my container. I followed mostly [official documentation](https://docs.aws.amazon.com/cdk/v2/guide/ecs_example.html)

This part, in particular, I believe caused this:
```java
Vpc vpc = Vpc.Builder.create(this, "MyVpc")
.maxAzs(3) // Default is all AZs in region
.build();
```

If I understood correctly, the default behavior is to create NAT Gateway and put service behind it. While I understand the reasoning behind it, I believe most people don't need it. For sure, no one wants unexpected bills. Please consider changing this default behavior. At the very least, there should be some disclaimer.

Btw, I'm still trying to figure out how to get rid of NAT. Simply adding `.natGateways(0)` doesn't work, causing some subnet conflicts when I try to update the existing stack. Seems like I have to learn how VPC works in AWS.

Contributor guide

Open the contributing guide

Research direction

Start with the linked ECS example and the Vpc.Builder configuration shown in the issue. Investigate how the default NAT Gateway and subnet layout are selected, including why changing natGateways to 0 causes conflicts during stack updates. Done means the requested default or a clear disclaimer is implemented and the existing deployment behavior is covered by validation or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.