-
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
fix(ec2): VpcEndpoint AZ lookup fails for AWS services #8386
Conversation
Any update on this? |
@@ -315,7 +315,11 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ | |||
public readonly privateDnsDefault?: boolean = true; | |||
|
|||
constructor(name: string, prefix?: string, port?: number) { | |||
this.name = `${prefix || 'com.amazonaws'}.${Aws.REGION}.${name}`; | |||
// this.name = `${prefix || 'com.amazonaws'}.${Aws.REGION}.${name}`; | |||
const region = Lazy.stringValue({ |
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.
This doesn't need to be lazy. Could just be Stack.of(context.scope).region
, has the same behavior.
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'm not sure what the code should be here. Here's what I've tried, all without success:
const region = Stack.of(context.scope).region;
Yields "cannot find name 'context'"
const region = {
produce: (context: any) => Stack.of(context.scope).region,
};
Results in a test failure because Stack.of(context.scope).region
resolves to an Object:
Field ServiceName mismatch: com.amazonaws.[object Object].execute-api !== com.amazonaws.us-east-1.execute-api,Field SubnetIds mismatch: element 1: Ref: VPCPrivateSubnet2SubnetCFCDAA7A !== VPCPrivateSubnet3Subnet3EDCD457 in:
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.
InterfaceVpcEndpointAwsService isn't a construct you don't have any context/scope/stack to use to get the region from. Using Lazy lets you get that context from wherever the InterfaceVpcEndpointAwsService is used.
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 see. You are correct good sir, my apologies.
208ce2c
to
8ab69f9
Compare
Updated to use the Jest unit tests. |
Any update on this? |
@@ -315,7 +315,11 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ | |||
public readonly privateDnsDefault?: boolean = true; | |||
|
|||
constructor(name: string, prefix?: string, port?: number) { | |||
this.name = `${prefix || 'com.amazonaws'}.${Aws.REGION}.${name}`; | |||
// this.name = `${prefix || 'com.amazonaws'}.${Aws.REGION}.${name}`; | |||
const region = Lazy.stringValue({ |
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 see. You are correct good sir, my apologies.
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). |
fix(ec2): VpcEndpoint AZ lookup fails for AWS services
This closes #8372
InterfaceVpcEndpointAwsService objects currently use the
AWS.Region
token to define the service name. This results in an unresolved string, which cannot be resolved until CloudFormation deployment time.When using the
lookupSupportedAzs
functionality, a ContextProvider makes AWS calls (DescribeVpcEndpointServices) in which it passes the service name, to look up the AZs. ContextProviders cannot be given tokens. Hence, passing in an InterfaceVpcEndpointAwsService results in a synthesis-time failure.This ticket switches InterfaceVpcEndpointAwsService from using AWS.Region to a Lazy string which resolves to the stack's region. For region-agnostic stacks, the behavior is unchanged. For stacks with a specified region, the region is resolved.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license