From 583813c623bbf17be4b51a6ea0adbe451a6027cc Mon Sep 17 00:00:00 2001 From: Shweta Sahu <34386180+shwetasahuit@users.noreply.github.com> Date: Wed, 20 Oct 2021 01:25:49 -0700 Subject: [PATCH] refactor(region-info): AppMesh ECR accounts for cn-north-1 and cn-northwest-1 (#16836) ---- AppMesh is launched in 'cn-noth-1' and 'cn-northwest-1' regions. These regions have separate accounts for storing Envoy images in ECR. Added the ECR account information. These regions belong to new partition 'aws-cn', removed the harcoded 'aws' partition and modified it to work for all partitions. *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .gitallowed | 2 ++ .../lib/extensions/appmesh.ts | 5 ++- .../integ.all-service-addons.expected.json | 36 +++++++++++++++++-- .../integ.multiple-environments.expected.json | 24 +++++++++++-- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/.gitallowed b/.gitallowed index 43827f7ad99b7..abe8ccb913ca4 100644 --- a/.gitallowed +++ b/.gitallowed @@ -23,6 +23,8 @@ account: '856666278305' account: '840364872350' account: '422531588944' account: '924023996002' +account: '919366029133' #cn-north-1 +account: '919830735681' #cn-northwest-1 # The account IDs of password rotation applications of Serverless Application Repository # https://docs.aws.amazon.com/secretsmanager/latest/userguide/enable-rotation-rds.html diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts index ccd9a2ece2bc2..14cd5aaecfdac 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts @@ -138,6 +138,7 @@ export class AppMeshExtension extends ServiceExtension { public useTaskDefinition(taskDefinition: ecs.TaskDefinition) { var region = cdk.Stack.of(this.scope).region; + var partition = cdk.Stack.of(this.scope).partition; var appMeshRepo; // This is currently necessary because App Mesh has different images in each region, @@ -151,6 +152,8 @@ export class AppMeshExtension extends ServiceExtension { 'ap-southeast-1': this.accountIdForRegion('ap-southeast-1'), 'ap-southeast-2': this.accountIdForRegion('ap-southeast-1'), 'ca-central-1': this.accountIdForRegion('ca-central-1'), + 'cn-north-1': this.accountIdForRegion('cn-north-1'), + 'cn-northwest-1': this.accountIdForRegion('cn-northwest-1'), 'eu-central-1': this.accountIdForRegion('eu-central-1'), 'eu-north-1': this.accountIdForRegion('eu-north-1'), 'eu-south-1': this.accountIdForRegion('eu-south-1'), @@ -177,7 +180,7 @@ export class AppMeshExtension extends ServiceExtension { `${this.parentService.id}-envoy-repo`, { repositoryName: 'aws-appmesh-envoy', - repositoryArn: `arn:aws:ecr:${region}:${ownerAccount}:repository/aws-appmesh-envoy`, + repositoryArn: `arn:${partition}:ecr:${region}:${ownerAccount}:repository/aws-appmesh-envoy`, }, ); diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json b/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json index 47ba97c3ee10d..afdf0319a819a 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json +++ b/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.all-service-addons.expected.json @@ -949,7 +949,11 @@ "Fn::Join": [ "", [ - "arn:aws:ecr:", + "arn:", + { + "Ref": "AWS::Partition" + }, + ":ecr:", { "Ref": "AWS::Region" }, @@ -1818,7 +1822,11 @@ "Fn::Join": [ "", [ - "arn:aws:ecr:", + "arn:", + { + "Ref": "AWS::Partition" + }, + ":ecr:", { "Ref": "AWS::Region" }, @@ -2806,7 +2814,11 @@ "Fn::Join": [ "", [ - "arn:aws:ecr:", + "arn:", + { + "Ref": "AWS::Partition" + }, + ":ecr:", { "Ref": "AWS::Region" }, @@ -3316,6 +3328,12 @@ "ca-central-1": { "ecrRepo": "840364872350" }, + "cn-north-1": { + "ecrRepo": "919366029133" + }, + "cn-northwest-1": { + "ecrRepo": "919830735681" + }, "eu-central-1": { "ecrRepo": "840364872350" }, @@ -3378,6 +3396,12 @@ "ca-central-1": { "ecrRepo": "840364872350" }, + "cn-north-1": { + "ecrRepo": "919366029133" + }, + "cn-northwest-1": { + "ecrRepo": "919830735681" + }, "eu-central-1": { "ecrRepo": "840364872350" }, @@ -3440,6 +3464,12 @@ "ca-central-1": { "ecrRepo": "840364872350" }, + "cn-north-1": { + "ecrRepo": "919366029133" + }, + "cn-northwest-1": { + "ecrRepo": "919830735681" + }, "eu-central-1": { "ecrRepo": "840364872350" }, diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.multiple-environments.expected.json b/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.multiple-environments.expected.json index 3a3aaddac6fce..d5f00cb5708c7 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.multiple-environments.expected.json +++ b/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.multiple-environments.expected.json @@ -1304,7 +1304,11 @@ "Fn::Join": [ "", [ - "arn:aws:ecr:", + "arn:", + { + "Ref": "AWS::Partition" + }, + ":ecr:", { "Ref": "AWS::Region" }, @@ -1828,7 +1832,11 @@ "Fn::Join": [ "", [ - "arn:aws:ecr:", + "arn:", + { + "Ref": "AWS::Partition" + }, + ":ecr:", { "Ref": "AWS::Region" }, @@ -2135,6 +2143,12 @@ "ca-central-1": { "ecrRepo": "840364872350" }, + "cn-north-1": { + "ecrRepo": "919366029133" + }, + "cn-northwest-1": { + "ecrRepo": "919830735681" + }, "eu-central-1": { "ecrRepo": "840364872350" }, @@ -2197,6 +2211,12 @@ "ca-central-1": { "ecrRepo": "840364872350" }, + "cn-north-1": { + "ecrRepo": "919366029133" + }, + "cn-northwest-1": { + "ecrRepo": "919830735681" + }, "eu-central-1": { "ecrRepo": "840364872350" },