-
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
feat(cli): VPC context provider looks up RouteTable IDs #3171
Conversation
- Correctly detect VPC without any subnets & abort with specific message. - Correctly validate that only valid aws-cdk:subnet-type values are present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job with the tests!
if (routeTableIds == null) { | ||
// Maintaining backwards-compatibility - this used to not be provided by the VPC Context Provider! | ||
// tslint:disable-next-line: max-line-length | ||
this.warning = `No routeTableIds were provided for subnets ${this.subnetIds.join(', ')}! Calling .routeTableId on these subnets will return undefined/null!`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it "throw" instead of returning undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd be a breaking change...
? `at '${scope.node.path}/${id}'` | ||
: `'${attrs.subnetId}'`; | ||
// tslint:disable-next-line: max-line-length | ||
scope.node.addWarning(`No routeTableId was provided to the subnet ${ref}. Attempting to read it's .routeTable.routeTableId will return null/undefined. (More info: https://github.com/aws/aws-cdk/pull/3171)`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: For anyone directed to this PR by the No routeTableId was provided to the subnet
warning message: See this issue: #19786, which about making this warning only appear when necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but how do I fix the actual warning? I need the route table ids to be pulled back so I can make use of them. Do I have to hard-code them in my config and use from_attributes( ... routeTableId ...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up fetching the subnets and route tables and marrying them via Subnet.fromSubnetAttributes
. Not ideal, but I'm sure there's a reason...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From linked issue, do something like:
cdk.Annotations.of(subnet).acknowledgeWarning(
"@aws-cdk/aws-ec2:noSubnetRouteTableId",
"Will not read route table ID for subnet",
);
Why, when fetching a subnet via lookup, is the |
Import RouteTableIds for subnets when looking up a VPC from the
VpcContextProvider
.This associates the Subnet-specific route table ID if there is one, and falls back to the
VPC's main route table otherwise.
Fixes #2487
Fixes #2926
Please read the contribution guidelines and follow the pull-request checklist.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license