Skip to content

Commit 2935b92

Browse files
authored
chore(ec2): update Interface VPC endpoints in China (#25333)
This PR updates all available VPC endpoints in China regions(cn-north-1 and cn-northwest-1). The list is retrieved from AWS CLI commands [here](#25329 (comment)). Closes #25329 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent b2dfac0 commit 2935b92

File tree

2 files changed

+118
-28
lines changed

2 files changed

+118
-28
lines changed

packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts

+14-13
Original file line numberDiff line numberDiff line change
@@ -514,19 +514,20 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ
514514
*/
515515
private getDefaultEndpointPrefix(name: string, region: string) {
516516
const VPC_ENDPOINT_SERVICE_EXCEPTIONS: { [region: string]: string[] } = {
517-
'cn-north-1': ['application-autoscaling', 'athena', 'autoscaling', 'awsconnector', 'cassandra',
518-
'cloudformation', 'codedeploy-commands-secure', 'databrew', 'dms', 'ebs', 'ec2', 'ecr.api', 'ecr.dkr',
519-
'elasticbeanstalk', 'elasticfilesystem', 'elasticfilesystem-fips', 'execute-api', 'imagebuilder',
520-
'iotsitewise.api', 'iotsitewise.data', 'kinesis-streams', 'lambda', 'license-manager', 'monitoring',
521-
'rds', 'redshift', 'redshift-data', 's3', 'sagemaker.api', 'sagemaker.featurestore-runtime',
522-
'sagemaker.runtime', 'servicecatalog', 'sms', 'sqs', 'states', 'sts', 'synthetics', 'transcribe',
523-
'transcribestreaming', 'transfer', 'xray'],
524-
'cn-northwest-1': ['application-autoscaling', 'athena', 'autoscaling', 'awsconnector', 'cassandra',
525-
'cloudformation', 'codedeploy-commands-secure', 'databrew', 'dms', 'ebs', 'ec2', 'ecr.api', 'ecr.dkr',
526-
'elasticbeanstalk', 'elasticfilesystem', 'elasticfilesystem-fips', 'execute-api', 'imagebuilder',
527-
'kinesis-streams', 'lambda', 'license-manager', 'monitoring', 'rds', 'redshift', 'redshift-data', 's3',
528-
'sagemaker.api', 'sagemaker.featurestore-runtime', 'sagemaker.runtime', 'servicecatalog', 'sms', 'sqs',
529-
'states', 'sts', 'synthetics', 'transcribe', 'transcribestreaming', 'transfer', 'workspaces', 'xray'],
517+
'cn-north-1': ['application-autoscaling', 'appmesh-envoy-management', 'athena', 'autoscaling', 'awsconnector',
518+
'backup', 'batch', 'cassandra', 'cloudcontrolapi', 'cloudformation', 'codedeploy-commands-secure', 'databrew', 'dms',
519+
'ebs', 'ec2', 'ecr.api', 'ecr.dkr', 'eks', 'elasticache', 'elasticbeanstalk', 'elasticfilesystem',
520+
'elasticfilesystem-fips', 'emr-containers', 'execute-api', 'fsx', 'imagebuilder', 'iot.data', 'iotsitewise.api',
521+
'iotsitewise.data', 'kinesis-streams', 'lambda', 'license-manager', 'monitoring', 'rds', 'redshift', 'redshift-data',
522+
's3', 'sagemaker.api', 'sagemaker.featurestore-runtime', 'sagemaker.runtime', 'securityhub', 'servicecatalog',
523+
'sms', 'sqs', 'states', 'sts', 'sync-states', 'synthetics', 'transcribe', 'transcribestreaming', 'transfer', 'xray'],
524+
'cn-northwest-1': ['account', 'application-autoscaling', 'appmesh-envoy-management', 'athena', 'autoscaling', 'awsconnector',
525+
'backup', 'batch', 'cassandra', 'cloudcontrolapi', 'cloudformation', 'codedeploy-commands-secure', 'databrew', 'dms', 'ebs', 'ec2',
526+
'ecr.api', 'ecr.dkr', 'eks', 'elasticache', 'elasticbeanstalk', 'elasticfilesystem', 'elasticfilesystem-fips', 'emr-containers',
527+
'execute-api', 'fsx', 'imagebuilder', 'iot.data', 'kinesis-streams', 'lambda', 'license-manager', 'monitoring', 'polly', 'rds',
528+
'redshift', 'redshift-data', 's3', 'sagemaker.api', 'sagemaker.featurestore-runtime', 'sagemaker.runtime', 'securityhub',
529+
'servicecatalog', 'sms', 'sqs', 'states', 'sts', 'sync-states', 'synthetics', 'transcribe', 'transcribestreaming', 'transfer',
530+
'workspaces', 'xray'],
530531
};
531532
if (VPC_ENDPOINT_SERVICE_EXCEPTIONS[region]?.includes(name)) {
532533
return 'cn.com.amazonaws';

packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint.test.ts

+104-15
Original file line numberDiff line numberDiff line change
@@ -717,40 +717,129 @@ describe('vpc endpoint', () => {
717717

718718

719719
});
720-
test('test vpc interface endpoint for transcribe can be created correctly in cn-north-1', () => {
720+
test.each([
721+
['transcribe', InterfaceVpcEndpointAwsService.TRANSCRIBE],
722+
])('test vpc interface endpoint with .cn suffix for %s can be created correctly in China regions', (name: string, given: InterfaceVpcEndpointAwsService) => {
723+
//GIVEN
724+
const stack1 = new Stack(undefined, 'TestStack', { env: { account: '123456789012', region: 'cn-north-1' } });
725+
const stack2 = new Stack(undefined, 'TestStack', { env: { account: '123456789012', region: 'cn-northwest-1' } });
726+
const vpc1 = new Vpc(stack1, 'VPC');
727+
const vpc2 = new Vpc(stack2, 'VPC');
728+
729+
//WHEN
730+
vpc1.addInterfaceEndpoint('Endpoint', { service: given });
731+
vpc2.addInterfaceEndpoint('Endpoint', { service: given });
732+
733+
//THEN
734+
Template.fromStack(stack1).hasResourceProperties('AWS::EC2::VPCEndpoint', {
735+
ServiceName: `cn.com.amazonaws.cn-north-1.${name}.cn`,
736+
});
737+
Template.fromStack(stack2).hasResourceProperties('AWS::EC2::VPCEndpoint', {
738+
ServiceName: `cn.com.amazonaws.cn-northwest-1.${name}.cn`,
739+
});
740+
});
741+
test.each([
742+
['application-autoscaling', InterfaceVpcEndpointAwsService.APPLICATION_AUTOSCALING],
743+
['appmesh-envoy-management', InterfaceVpcEndpointAwsService.APP_MESH],
744+
['athena', InterfaceVpcEndpointAwsService.ATHENA],
745+
['autoscaling', InterfaceVpcEndpointAwsService.AUTOSCALING],
746+
['awsconnector', InterfaceVpcEndpointAwsService.SERVER_MIGRATION_SERVICE_AWSCONNECTOR],
747+
['backup', InterfaceVpcEndpointAwsService.BACKUP],
748+
['batch', InterfaceVpcEndpointAwsService.BATCH],
749+
['cassandra', InterfaceVpcEndpointAwsService.KEYSPACES],
750+
['cloudcontrolapi', InterfaceVpcEndpointAwsService.CLOUD_CONTROL_API],
751+
['cloudformation', InterfaceVpcEndpointAwsService.CLOUDFORMATION],
752+
['cloudformation', InterfaceVpcEndpointAwsService.CLOUDFORMATION],
753+
['codedeploy-commands-secure', InterfaceVpcEndpointAwsService.CODEDEPLOY_COMMANDS_SECURE],
754+
['databrew', InterfaceVpcEndpointAwsService.GLUE_DATABREW],
755+
['dms', InterfaceVpcEndpointAwsService.DATABASE_MIGRATION_SERVICE],
756+
['ebs', InterfaceVpcEndpointAwsService.EBS_DIRECT],
757+
['ec2', InterfaceVpcEndpointAwsService.EC2],
758+
['ecr.api', InterfaceVpcEndpointAwsService.ECR],
759+
['ecr.dkr', InterfaceVpcEndpointAwsService.ECR_DOCKER],
760+
['eks', InterfaceVpcEndpointAwsService.EKS],
761+
['elasticache', InterfaceVpcEndpointAwsService.ELASTICACHE],
762+
['elasticbeanstalk', InterfaceVpcEndpointAwsService.ELASTIC_BEANSTALK],
763+
['elasticfilesystem', InterfaceVpcEndpointAwsService.ELASTIC_FILESYSTEM],
764+
['elasticfilesystem-fips', InterfaceVpcEndpointAwsService.ELASTIC_FILESYSTEM_FIPS],
765+
['emr-containers', InterfaceVpcEndpointAwsService.EMR_EKS],
766+
['execute-api', InterfaceVpcEndpointAwsService.APIGATEWAY],
767+
['fsx', InterfaceVpcEndpointAwsService.FSX],
768+
['imagebuilder', InterfaceVpcEndpointAwsService.IMAGE_BUILDER],
769+
['iot.data', InterfaceVpcEndpointAwsService.IOT_CORE],
770+
['kinesis-streams', InterfaceVpcEndpointAwsService.KINESIS_STREAMS],
771+
['lambda', InterfaceVpcEndpointAwsService.LAMBDA],
772+
['license-manager', InterfaceVpcEndpointAwsService.LICENSE_MANAGER],
773+
['monitoring', InterfaceVpcEndpointAwsService.CLOUDWATCH_MONITORING],
774+
['rds', InterfaceVpcEndpointAwsService.RDS],
775+
['redshift', InterfaceVpcEndpointAwsService.REDSHIFT],
776+
['redshift-data', InterfaceVpcEndpointAwsService.REDSHIFT_DATA],
777+
['s3', InterfaceVpcEndpointAwsService.S3],
778+
['sagemaker.api', InterfaceVpcEndpointAwsService.SAGEMAKER_API],
779+
['sagemaker.featurestore-runtime', InterfaceVpcEndpointAwsService.SAGEMAKER_FEATURESTORE_RUNTIME],
780+
['sagemaker.runtime', InterfaceVpcEndpointAwsService.SAGEMAKER_RUNTIME],
781+
['securityhub', InterfaceVpcEndpointAwsService.SECURITYHUB],
782+
['servicecatalog', InterfaceVpcEndpointAwsService.SERVICE_CATALOG],
783+
['sms', InterfaceVpcEndpointAwsService.SERVER_MIGRATION_SERVICE],
784+
['sqs', InterfaceVpcEndpointAwsService.SQS],
785+
['states', InterfaceVpcEndpointAwsService.STEP_FUNCTIONS],
786+
['states', InterfaceVpcEndpointAwsService.STEP_FUNCTIONS],
787+
['sts', InterfaceVpcEndpointAwsService.STS],
788+
['sync-states', InterfaceVpcEndpointAwsService.STEP_FUNCTIONS_SYNC],
789+
['synthetics', InterfaceVpcEndpointAwsService.CLOUDWATCH_SYNTHETICS],
790+
['transcribestreaming', InterfaceVpcEndpointAwsService.TRANSCRIBE_STREAMING],
791+
['transfer', InterfaceVpcEndpointAwsService.TRANSFER],
792+
['xray', InterfaceVpcEndpointAwsService.XRAY],
793+
])('test vpc interface endpoint for %s can be created correctly in China regions', (name: string, given: InterfaceVpcEndpointAwsService) => {
794+
//GIVEN
795+
const stack1 = new Stack(undefined, 'TestStack', { env: { account: '123456789012', region: 'cn-north-1' } });
796+
const stack2 = new Stack(undefined, 'TestStack', { env: { account: '123456789012', region: 'cn-northwest-1' } });
797+
const vpc1 = new Vpc(stack1, 'VPC');
798+
const vpc2 = new Vpc(stack2, 'VPC');
799+
800+
//WHEN
801+
vpc1.addInterfaceEndpoint('Endpoint', { service: given });
802+
vpc2.addInterfaceEndpoint('Endpoint', { service: given });
803+
804+
//THEN
805+
Template.fromStack(stack1).hasResourceProperties('AWS::EC2::VPCEndpoint', {
806+
ServiceName: `cn.com.amazonaws.cn-north-1.${name}`,
807+
});
808+
Template.fromStack(stack2).hasResourceProperties('AWS::EC2::VPCEndpoint', {
809+
ServiceName: `cn.com.amazonaws.cn-northwest-1.${name}`,
810+
});
811+
});
812+
test.each([
813+
['iotsitewise.api', InterfaceVpcEndpointAwsService.IOT_SITEWISE_API],
814+
['iotsitewise.data', InterfaceVpcEndpointAwsService.IOT_SITEWISE_DATA],
815+
])('test vpc interface endpoint for %s can be created correctly in cn-north-1 only', (name: string, given: InterfaceVpcEndpointAwsService) => {
721816
//GIVEN
722817
const stack = new Stack(undefined, 'TestStack', { env: { account: '123456789012', region: 'cn-north-1' } });
723818
const vpc = new Vpc(stack, 'VPC');
724819

725820
//WHEN
726-
vpc.addInterfaceEndpoint('Transcribe Endpoint', {
727-
service: InterfaceVpcEndpointAwsService.TRANSCRIBE,
728-
});
821+
vpc.addInterfaceEndpoint('Endpoint', { service: given });
729822

730823
//THEN
731824
Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPCEndpoint', {
732-
ServiceName: 'cn.com.amazonaws.cn-north-1.transcribe.cn',
825+
ServiceName: `cn.com.amazonaws.cn-north-1.${name}`,
733826
});
734-
735-
736827
});
737-
738-
test('test vpc interface endpoint for transcribe can be created correctly in cn-northwest-1', () => {
828+
test.each([
829+
['account', InterfaceVpcEndpointAwsService.ACCOUNT_MANAGEMENT],
830+
['workspaces', InterfaceVpcEndpointAwsService.WORKSPACES],
831+
])('test vpc interface endpoint for %s can be created correctly in cn-northwest-1 only', (name: string, given: InterfaceVpcEndpointAwsService) => {
739832
//GIVEN
740833
const stack = new Stack(undefined, 'TestStack', { env: { account: '123456789012', region: 'cn-northwest-1' } });
741834
const vpc = new Vpc(stack, 'VPC');
742835

743836
//WHEN
744-
vpc.addInterfaceEndpoint('Transcribe Endpoint', {
745-
service: InterfaceVpcEndpointAwsService.TRANSCRIBE,
746-
});
837+
vpc.addInterfaceEndpoint('Endpoint', { service: given });
747838

748839
//THEN
749840
Template.fromStack(stack).hasResourceProperties('AWS::EC2::VPCEndpoint', {
750-
ServiceName: 'cn.com.amazonaws.cn-northwest-1.transcribe.cn',
841+
ServiceName: `cn.com.amazonaws.cn-northwest-1.${name}`,
751842
});
752-
753-
754843
});
755844

756845
test('test codeartifact vpc interface endpoint in us-west-2', () => {

0 commit comments

Comments
 (0)