-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(aws-ec2): SubnetSelection Returns - Error: Cannot create a VPC Endpoint with no subnets #32460
Comments
Reproducible after running {
"availability-zones:account=<<ACCOUNT-ID>>:region=us-east-2": [
"us-east-2a",
"us-east-2b",
"us-east-2c"
]
}
Thereafter, reverting to use The error occurs when defining const InterfaceEndpoint = new ec2.InterfaceVpcEndpoint(this, 'Replication Endpoint', {
vpc: vpc,
service: ec2.InterfaceVpcEndpointAwsService.SECRETS_MANAGER,
subnets: {
availabilityZones: ["us-east-1a"]
}
}); |
internal: P176585888 |
Thanks @pahud for reviewing the priority. |
Hello thanks for creating an issue. I deep dived into this problem and here's my finding: SummaryIn your example, you specified the availability zone for VPC endpoint, thus CDK will filter your subnets that match the availability zone in this line. What happened was that CDK was not able to find a subnet that match the availability zone and thus returning the error message that you saw. Possible reasonIf your CDK stack specifies AWS account and region and they are not unresolved values, what will happen is that CDK will look for context value in your
This will allow CDK to determine the availability zone of the subnets created. On the other hand, if your CDK stack is region and account agnostic (i.e. CDK can't determine the stack region or account), it will look for context value WorkaroundYou can either use the method mentioned by @ashishdhingra to reset the availability context values or you can manually specify the context value by adding the following manually to your
I'm going to mark this issue as resolved, feel free to reopen this or create a new issue if you have additional question or need additional support. Happy new year! |
Comments on closed issues and PRs are hard for our team to see. |
Describe the bug
When creating a Interface VPC Endpoint and using the
availabilityZones
filter on theSubnets
property you will get a "Error: Cannot create a VPC Endpoint with no subnets" message when no context is present incdk.context.json
.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
The
availabilityZones
is a property of theSubnetSelection
interface. The expectation here is that setting an availability zone will filter all the subnets and only specify the ones that match that availability zone.Current Behavior
Currently, the following validation error is being returned: "Error: Cannot create a VPC Endpoint with no subnets."
Reproduction Steps
Using the following code snippet, perform a
cdk synth
and ensure yourcdk.context.json
file is empty.Possible Solution
No response
Additional Information/Context
When creating the VPC, use the
availabilityZones
property instead of themaxAzs
property. When the VPC created makes use of theavailabilityZones
property, this error does not occur.Testing with other constructs that implement the
SubnetSelection
interface, I confirmed that with an emptycdk.context.json
and specifying theavailabilityZones
property, no subnets will be returned.CDK CLI Version
2.171.0
Framework Version
No response
Node.js Version
v22.2.0
OS
macOS
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: