-
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
aws_ec2: vpc.fromLookup doesn't set env.region correctly #22178
Comments
Thanks for reporting this @cartalla, I can confirm this behavior hasn't been fixed. Outputting the region of a Vpc looked up from region us-east-1 in a stack deploying to us-west-2 will give me us-west-2. @daschaa @TheRealAmazonKendra The integration test in the PR seems to cover this exact case, however it's not working in practice. Could you take another look at this? |
yeah, we got around it with the following, manually specifying via VPCProperty in CfnHostedZone. CfnHostedZone(
self,
"id goes here",
name = "domain name goes here",
vpcs = [
CfnHostedZone.VPCProperty(vpc_id="us-east-1 VPC ID goes here", vpc_region = "us-east-1"),
CfnHostedZone.VPCProperty(vpc_id="us-east-2 VPC ID goes here", vpc_region = "us-east-2")
]
) |
There is a bug in the CDK that was preventing Vpc.from_lookup() from working: aws/aws-cdk#22178 To solve it i changed the root project structure from 4 separate repos each with its cdk app to one cdk app with all the stacks In doing so, I replaced CfnOutput and Fn.import_value for explicitly passing the dependencies between stacks as arguments.
Fyi; this bug still exists. |
Describe the bug
The context is that the bug fix for #20496 and #20530 did not resolve the problem with the Route53.add_vpc() call not setting the region for the VPC correctly. The addVpc function is now using vpc.env.region if it is set, but the problem is that it is not set correctly to match the value in cdk.context.json and set the region from the stack instead.
Expected Behavior
The template should have the correction region set for the VPC.
Current Behavior
The resulting CFN template has the correct VpcIds, but the incorrect regions:
Reproduction Steps
I'm creating a Route53.HostedZone for use in 3 VPCs that are located in 3 different regions.
The VPCs aren't part of the stack and are created in CDK using
This causes an update to cdk.context.json where the VPC ids and regions are correct.
Extract from cdk.context.json:
I create the Hosted Zone:
Possible Solution
I'm not familiar with the context provider, but it either it's not returning the correct region or the VPC constructor isn't using it.
https://github.com/aws/aws-cdk/blob/v1-main/packages/%40aws-cdk/aws-ec2/lib/vpc.ts#L1167-L1178
Additional Information/Context
No response
CDK CLI Version
2.42.1
Framework Version
No response
Node.js Version
16.15.0
OS
AmazonLinux2
Language
Python
Language Version
Python 3.7.10
Other information
No response
The text was updated successfully, but these errors were encountered: