-
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
fix: (aws-ec2): fix vpc endpoint incorrect issue in China region #16139
fix: (aws-ec2): fix vpc endpoint incorrect issue in China region #16139
Conversation
Title does not follow the guidelines of Conventional Commits. Please adjust title before merge. |
@@ -326,9 +326,32 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ | |||
const region = Lazy.uncachedString({ | |||
produce: (context) => Stack.of(context.scope).region, | |||
}); | |||
this.name = `${prefix || 'com.amazonaws'}.${region}.${name}`; | |||
const regionPrefix =Lazy.uncachedString({ |
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.
const regionPrefix =Lazy.uncachedString({ | |
const defaultEndpointPrefix =Lazy.uncachedString({ |
How about just call it defaultEndpointPrefix
?
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 @pahud, that's a good suggestion, I'll update it.
'cn-north-1': ['application-autoscaling', 'athena', 'autoscaling', 'awsconnector', 'cassandra', 'cloudformation', 'codedeploy-commands-secure', 'databrew', 'dms', 'ebs', 'ec2', 'ecr.api', 'ecr.dkr', 'elasticbeanstalk', 'elasticfilesystem', 'elasticfilesystem-fips', 'execute-api', 'imagebuilder', 'iotsitewise.api', 'iotsitewise.data', 'kinesis-streams', 'lambda', 'license-manager', 'monitoring', 'rds', 'redshift', 'redshift-data', 's3', 'sagemaker.api', 'sagemaker.featurestore-runtime', 'sagemaker.runtime', 'servicecatalog', 'sms', 'sqs', 'states', 'sts', 'synthetics', 'transcribe.cn', 'transcribestreaming', 'transfer', 'xray'], | ||
'cn-northwest-1': ['application-autoscaling', 'athena', 'autoscaling', 'awsconnector', 'cassandra', 'cloudformation', 'codedeploy-commands-secure', 'databrew', 'dms', 'ebs', 'ec2', 'ecr.api', 'ecr.dkr', 'elasticbeanstalk', 'elasticfilesystem', 'elasticfilesystem-fips', 'execute-api', 'imagebuilder', 'kinesis-streams', 'lambda', 'license-manager', 'monitoring', 'rds', 'redshift', 'redshift-data', 's3', 'sagemaker.api', 'sagemaker.featurestore-runtime', 'sagemaker.runtime', 'servicecatalog', 'sms', 'sqs', 'states', 'sts', 'synthetics', 'transcribe.cn', 'transcribestreaming', 'transfer', 'workspaces', 'xray'], |
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.
Let's wrap the lines to make it more readable.
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 suggestions, thanks Pahud
/** | ||
* Get the endpoint prefix for the service in the specified region | ||
* because the prefix for some of the services in cn-north-1 and cn-northwest-1 are different | ||
*/ |
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.
Maybe we can add an AWS CLI sample in the doc comments showing how to get all endpoints from a region. That would be helpful.
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.
ok, I'll add the AWS CLI sample to the comments
'cn-north-1': ['application-autoscaling', 'athena', 'autoscaling', 'awsconnector', 'cassandra', 'cloudformation', 'codedeploy-commands-secure', 'databrew', 'dms', 'ebs', 'ec2', 'ecr.api', 'ecr.dkr', 'elasticbeanstalk', 'elasticfilesystem', 'elasticfilesystem-fips', 'execute-api', 'imagebuilder', 'iotsitewise.api', 'iotsitewise.data', 'kinesis-streams', 'lambda', 'license-manager', 'monitoring', 'rds', 'redshift', 'redshift-data', 's3', 'sagemaker.api', 'sagemaker.featurestore-runtime', 'sagemaker.runtime', 'servicecatalog', 'sms', 'sqs', 'states', 'sts', 'synthetics', 'transcribe.cn', 'transcribestreaming', 'transfer', 'xray'], | ||
'cn-northwest-1': ['application-autoscaling', 'athena', 'autoscaling', 'awsconnector', 'cassandra', 'cloudformation', 'codedeploy-commands-secure', 'databrew', 'dms', 'ebs', 'ec2', 'ecr.api', 'ecr.dkr', 'elasticbeanstalk', 'elasticfilesystem', 'elasticfilesystem-fips', 'execute-api', 'imagebuilder', 'kinesis-streams', 'lambda', 'license-manager', 'monitoring', 'rds', 'redshift', 'redshift-data', 's3', 'sagemaker.api', 'sagemaker.featurestore-runtime', 'sagemaker.runtime', 'servicecatalog', 'sms', 'sqs', 'states', 'sts', 'synthetics', 'transcribe.cn', 'transcribestreaming', 'transfer', 'workspaces', 'xray'], | ||
}; | ||
if (VPC_ENDPOINT_SERVICE_EXCEPTIONS.hasOwnProperty(region) && VPC_ENDPOINT_SERVICE_EXCEPTIONS[region].includes(name)) { |
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.
if (VPC_ENDPOINT_SERVICE_EXCEPTIONS.hasOwnProperty(region) && VPC_ENDPOINT_SERVICE_EXCEPTIONS[region].includes(name)) { | |
if (VPC_ENDPOINT_SERVICE_EXCEPTIONS[region] && VPC_ENDPOINT_SERVICE_EXCEPTIONS[region].includes(name)) { |
I believe this should be working.
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.
It will be more concise, thanks Pahud for your suggestion, I'll update it
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.
just some minor suggested changes.
…CEPTIONS has the property of region
…readybuilderone/aws-cdk into fix-vpc-endpoint-issue-in-china
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 @readybuilderone , and thanks @pahud for the first-round review!
I think it's worth getting the transcribe
edge case right before we merge this; otherwise it looks great.
'elasticbeanstalk', 'elasticfilesystem', 'elasticfilesystem-fips', 'execute-api', 'imagebuilder', | ||
'iotsitewise.api', 'iotsitewise.data', 'kinesis-streams', 'lambda', 'license-manager', 'monitoring', | ||
'rds', 'redshift', 'redshift-data', 's3', 'sagemaker.api', 'sagemaker.featurestore-runtime', | ||
'sagemaker.runtime', 'servicecatalog', 'sms', 'sqs', 'states', 'sts', 'synthetics', 'transcribe.cn', |
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 think transcribe.cn
is an additional edge case. Based on the data here, it looks like it's the single case of a region-specific suffix. As-is, the name
input to this function will never be transcribe.cn
, so the exception will never be properly picked up. I guess we could create a corresponding getDefaultEndpointSuffix with just transcribe as the exception? What do you think?
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.
You're right, the .cn suffix should be handled for transcribe in China region.
this.name = `${prefix || defaultEndpointPrefix}.${region}.${name}${defaultEndpointSuffix}`;
I'll implement the getDefaultEndpointSuffix function and add the relative unit 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.
I have updated my implementation and added the unit tests. Am I doing the right way? @njlynch
Co-authored-by: Nick Lynch <nlynch@amazon.com>
It's really a great way to use "?.includes" to check the property exist, I have learned it, thanks @njlynch! Co-authored-by: Nick Lynch <nlynch@amazon.com>
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.
Looks great, thanks!
Looks like there is a |
Yes, this is my first PR to CDK, thanks @pahud and @njlynch so much! |
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). |
Nope, you're good. I just had to re-click the approve button, as the review was dismissed after the merge. It's in the queue to be automatically merged now, and should be merged shortly. |
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). |
…#16139) fix:(aws-ec2): fix vpc endpoint incorrect issue in China region This PR fix the issue that can't create interface vpc endpoint for 40+ services like ecr, ec2, athena etc Closes: aws#9864 ---- # Considerations 1. In cn-north-1 region, there are: - 2 services whose endpoint service begin with "aws.sagemaker" prefix; - 41 services whose endpoint service begin with "cn.com.amazonaws" prefix; - 21 services whose endpoint service begin with "com.amazonaws" prefix; Details: https://gist.github.com/readybuilderone/d355f9f8f0f2b66379a10742b3c67cc7 2. in cn-northwest-1 region, there are: - 2 services whose endpoint service begin with "aws.sagemaker" prefix; - 44 services whose endpoint service begin with "cn.com.amazonaws" prefix; - 21 services whose endpoint service begin with "com.amazonaws" prefix; Details: https://gist.github.com/readybuilderone/a79f2c5e6fa02aae1699bf674b08be7c So, In cn-north-1 and cn-northwest-1, the vpc endpoint prefix is both region and service related. At first, I found the vpc endpoint prefix could be fetched via [AWS API](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcEndpoints.html) , however the javascript sdk supports only asynchronous call, currently I didn't find any pattern in CDK to make live calls in object construction. Since the exception rules won't ever change ( only be added to), and the rate of change should be small in the grand scheme, I just kept the exception prefix lists in a map as fact data. # Known Issues Since the interface vpc endpoints prefixs are not region agnostic, it requires to set the {region} in the environment to create stacks in cn-north-1, and cn-northwest-1. The methods could be found in the [offical guide](https://docs.aws.amazon.com/cdk/latest/guide/environments.html). *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…#16139) fix:(aws-ec2): fix vpc endpoint incorrect issue in China region This PR fix the issue that can't create interface vpc endpoint for 40+ services like ecr, ec2, athena etc Closes: aws#9864 ---- # Considerations 1. In cn-north-1 region, there are: - 2 services whose endpoint service begin with "aws.sagemaker" prefix; - 41 services whose endpoint service begin with "cn.com.amazonaws" prefix; - 21 services whose endpoint service begin with "com.amazonaws" prefix; Details: https://gist.github.com/readybuilderone/d355f9f8f0f2b66379a10742b3c67cc7 2. in cn-northwest-1 region, there are: - 2 services whose endpoint service begin with "aws.sagemaker" prefix; - 44 services whose endpoint service begin with "cn.com.amazonaws" prefix; - 21 services whose endpoint service begin with "com.amazonaws" prefix; Details: https://gist.github.com/readybuilderone/a79f2c5e6fa02aae1699bf674b08be7c So, In cn-north-1 and cn-northwest-1, the vpc endpoint prefix is both region and service related. At first, I found the vpc endpoint prefix could be fetched via [AWS API](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcEndpoints.html) , however the javascript sdk supports only asynchronous call, currently I didn't find any pattern in CDK to make live calls in object construction. Since the exception rules won't ever change ( only be added to), and the rate of change should be small in the grand scheme, I just kept the exception prefix lists in a map as fact data. # Known Issues Since the interface vpc endpoints prefixs are not region agnostic, it requires to set the {region} in the environment to create stacks in cn-north-1, and cn-northwest-1. The methods could be found in the [offical guide](https://docs.aws.amazon.com/cdk/latest/guide/environments.html). *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…#16139) fix:(aws-ec2): fix vpc endpoint incorrect issue in China region This PR fix the issue that can't create interface vpc endpoint for 40+ services like ecr, ec2, athena etc Closes: aws#9864 ---- # Considerations 1. In cn-north-1 region, there are: - 2 services whose endpoint service begin with "aws.sagemaker" prefix; - 41 services whose endpoint service begin with "cn.com.amazonaws" prefix; - 21 services whose endpoint service begin with "com.amazonaws" prefix; Details: https://gist.github.com/readybuilderone/d355f9f8f0f2b66379a10742b3c67cc7 2. in cn-northwest-1 region, there are: - 2 services whose endpoint service begin with "aws.sagemaker" prefix; - 44 services whose endpoint service begin with "cn.com.amazonaws" prefix; - 21 services whose endpoint service begin with "com.amazonaws" prefix; Details: https://gist.github.com/readybuilderone/a79f2c5e6fa02aae1699bf674b08be7c So, In cn-north-1 and cn-northwest-1, the vpc endpoint prefix is both region and service related. At first, I found the vpc endpoint prefix could be fetched via [AWS API](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcEndpoints.html) , however the javascript sdk supports only asynchronous call, currently I didn't find any pattern in CDK to make live calls in object construction. Since the exception rules won't ever change ( only be added to), and the rate of change should be small in the grand scheme, I just kept the exception prefix lists in a map as fact data. # Known Issues Since the interface vpc endpoints prefixs are not region agnostic, it requires to set the {region} in the environment to create stacks in cn-north-1, and cn-northwest-1. The methods could be found in the [offical guide](https://docs.aws.amazon.com/cdk/latest/guide/environments.html). *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
fix:(aws-ec2): fix vpc endpoint incorrect issue in China region
This PR fix the issue that can't create interface vpc endpoint for 40+ services like ecr, ec2, athena etc
Closes: #9864
Considerations
Details: https://gist.github.com/readybuilderone/d355f9f8f0f2b66379a10742b3c67cc7
Details: https://gist.github.com/readybuilderone/a79f2c5e6fa02aae1699bf674b08be7c
So, In cn-north-1 and cn-northwest-1, the vpc endpoint prefix is both region and service related.
At first, I found the vpc endpoint prefix could be fetched via AWS API , however the javascript sdk supports only asynchronous call, currently I didn't find any pattern in CDK to make live calls in object construction. Since the exception rules won't ever change ( only be added to), and the rate of change should be small in the grand scheme, I just kept the exception prefix lists in a map as fact data.
Known Issues
Since the interface vpc endpoints prefixs are not region agnostic, it requires to set the {region} in the environment to create stacks in cn-north-1, and cn-northwest-1. The methods could be found in the offical guide.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license