-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ec2: NatProvider.instanceV2
does not work when mapPublicIpOnLaunch=false
for public subnets
#31711
Comments
Hi @tmokmss , thanks for reaching out. The property
As mentioned in CDK Docs, not assigning public IP when mapPublicIpOnLaunch=false, is intentional as mentioned in here -
and one can always assign public Ip addresses manually, by using Elastic IP Addresses. AFAIU, and if my understanding is correct, this is by design to keep it disabled. Please feel free to correct me if something is misunderstood. I would also reach out to core team and request their insights on the implementation of this concept. |
Thanks @khushail for the investigation!
I'm afraid not. Without public IP addresses, NAT instances won't work. This is a surprising behavior because users expect So a straightforward solution would be to expose a prop to assign a public IP address to the NAT instance when configuring NatProvider.instanceV2. In aws-cdk/packages/aws-cdk-lib/aws-ec2/lib/nat.ts Lines 536 to 547 in fbc28bc
|
thanks @tmokmss for the clarification there. Your solution makes sense. |
Comments on closed issues and PRs are hard for our team to see. |
1 similar comment
Comments on closed issues and PRs are hard for our team to see. |
Describe the bug
When we set
mapPublicIpOnLaunch=false
for public subnets, NAT instances does not get public IP addresses assigned, resulting in non-working NAT instances.Disabling mapPublicIpOnLaunch is recommended as AWS Config rule (and cdk-nag as well.)
https://docs.aws.amazon.com/config/latest/developerguide/subnet-auto-assign-public-ip-disabled.html
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
NAT instance works.
Current Behavior
NAT instance does not work.
Reproduction Steps
Deploy the below VPC, and you can see the NAT instances does not have public IP addresses assigned; traffic cannot go to the Internet because of that.
Possible Solution
Expose associatePublicIpAddress property maybe?
Additional Information/Context
No response
CDK CLI Version
2.160.0
Framework Version
No response
Node.js Version
20
OS
macos
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: