-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix(ec2): can't use imported Subnets in a SubnetSelection #9579
Conversation
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.
The title does not really describe what's wrong.
A simpler fix is to turn this into a getter:
https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-ec2/lib/vpc.ts#L348
get availabilityZones(): { return subnets.map(s => s.availabilityZone); },
Which (should) make it so that the evaluation of availabilityZone
is only done when it's actually requested by a construct.
public selectSubnets(selection: SubnetSelection = {}): SelectedSubnets {
const subnets = this.selectSubnetObjects(selection);
const pubs = new Set(this.publicSubnets);
return {
subnetIds: subnets.map(s => s.subnetId),
get availabilityZones(): string[] { return subnets.map(s => s.availabilityZone); },
internetConnectivityEstablished: tap(new CompositeDependable(), d => subnets.forEach(s => d.add(s.internetConnectivityEstablished))),
subnets,
hasPublic: subnets.some(s => pubs.has(s)),
};
} That seems to have done it. Any thoughts on returning a CFN reference if the AZ is referenced, but wasn't provided in the subnet lookup? Technically it would work for region-agnostic templates. |
I don't see how that will work though. How will:
Resolve to the availability zone of subnet (The first argument to EDIT: It's definitely not documented here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html |
I didn't read the documentation carefully enough -- you're right, we don't get a logical ID from a subnet import. Ok I'll scrap that part of the code. |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Closes #8301
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license