Skip to content

Commit c989fa4

Browse files
authored
fix(ecs): make URL domain-suffix dependent (#3394)
The ECS registry URL should be suffixed with the current partition's URL suffix, instead of a hard-coded `amazonaws.com`. Fixes #3377
1 parent 2747a76 commit c989fa4

File tree

13 files changed

+146
-101
lines changed

13 files changed

+146
-101
lines changed

packages/@aws-cdk/aws-codebuild/test/integ.docker-asset.lit.expected.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C",
4646
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17"
4747
],
48-
"DeletionPolicy": "Delete",
49-
"UpdateReplacePolicy": "Delete"
48+
"UpdateReplacePolicy": "Delete",
49+
"DeletionPolicy": "Delete"
5050
},
5151
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": {
5252
"Type": "AWS::IAM::Role",
@@ -428,7 +428,11 @@
428428
}
429429
]
430430
},
431-
".amazonaws.com/",
431+
".",
432+
{
433+
"Ref": "AWS::URLSuffix"
434+
},
435+
"/",
432436
{
433437
"Fn::GetAtt": [
434438
"MyImageAdoptRepository6CA902F6",
@@ -469,4 +473,4 @@
469473
}
470474
}
471475
}
472-
}
476+
}

packages/@aws-cdk/aws-codebuild/test/integ.ecr.lit.expected.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"Resources": {
33
"MyRepoF4F48043": {
4-
"DeletionPolicy": "Retain",
5-
"UpdateReplacePolicy": "Retain",
64
"Type": "AWS::ECR::Repository",
5+
"UpdateReplacePolicy": "Retain",
76
"DeletionPolicy": "Retain"
87
},
98
"MyProjectRole9BBE5233": {
@@ -170,7 +169,11 @@
170169
}
171170
]
172171
},
173-
".amazonaws.com/",
172+
".",
173+
{
174+
"Ref": "AWS::URLSuffix"
175+
},
176+
"/",
174177
{
175178
"Ref": "MyRepoF4F48043"
176179
},
@@ -195,4 +198,4 @@
195198
}
196199
}
197200
}
198-
}
201+
}

packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecs-deploy.expected.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@
195195
},
196196
"EcrRepoBB83A592": {
197197
"Type": "AWS::ECR::Repository",
198-
"DeletionPolicy": "Retain",
199-
"UpdateReplacePolicy": "Retain"
198+
"UpdateReplacePolicy": "Retain",
199+
"DeletionPolicy": "Retain"
200200
},
201201
"TaskDefTaskRole1EDB4A67": {
202202
"Type": "AWS::IAM::Role",
@@ -317,8 +317,8 @@
317317
"Status": "Enabled"
318318
}
319319
},
320-
"DeletionPolicy": "Delete",
321-
"UpdateReplacePolicy": "Delete"
320+
"UpdateReplacePolicy": "Delete",
321+
"DeletionPolicy": "Delete"
322322
},
323323
"EcsProjectRoleE2F0E9D2": {
324324
"Type": "AWS::IAM::Role",
@@ -536,7 +536,11 @@
536536
}
537537
]
538538
},
539-
".amazonaws.com/",
539+
".",
540+
{
541+
"Ref": "AWS::URLSuffix"
542+
},
543+
"/",
540544
{
541545
"Ref": "EcrRepoBB83A592"
542546
}
@@ -1071,4 +1075,4 @@
10711075
}
10721076
}
10731077
}
1074-
}
1078+
}

packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.expected.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C",
4646
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17"
4747
],
48-
"DeletionPolicy": "Delete",
49-
"UpdateReplacePolicy": "Delete"
48+
"UpdateReplacePolicy": "Delete",
49+
"DeletionPolicy": "Delete"
5050
},
5151
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": {
5252
"Type": "AWS::IAM::Role",
@@ -299,7 +299,11 @@
299299
}
300300
]
301301
},
302-
".amazonaws.com/",
302+
".",
303+
{
304+
"Ref": "AWS::URLSuffix"
305+
},
306+
"/",
303307
{
304308
"Fn::GetAtt": [
305309
"DockerImageAdoptRepositoryA86481BC",
@@ -325,4 +329,4 @@
325329
}
326330
}
327331
}
328-
}
332+
}

packages/@aws-cdk/aws-ecr/lib/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ export abstract class RepositoryBase extends Resource implements IRepository {
120120
*/
121121
public repositoryUriForTag(tag?: string): string {
122122
const tagSuffix = tag ? `:${tag}` : '';
123-
const parts = Stack.of(this).parseArn(this.repositoryArn);
124-
return `${parts.account}.dkr.ecr.${parts.region}.amazonaws.com/${this.repositoryName}${tagSuffix}`;
123+
const parts = this.stack.parseArn(this.repositoryArn);
124+
return `${parts.account}.dkr.ecr.${parts.region}.${this.stack.urlSuffix}/${this.repositoryName}${tagSuffix}`;
125125
}
126126

127127
/**

packages/@aws-cdk/aws-ecr/test/integ.basic.expected.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@
5050
}
5151
]
5252
},
53-
".amazonaws.com/",
53+
".",
54+
{
55+
"Ref": "AWS::URLSuffix"
56+
},
57+
"/",
5458
{
5559
"Ref": "Repo02AC86CF"
5660
}

packages/@aws-cdk/aws-ecr/test/test.repository.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ export = {
165165
{ 'Fn::Select': [ 4, arnSplit ] },
166166
'.dkr.ecr.',
167167
{ 'Fn::Select': [ 3, arnSplit ] },
168-
'.amazonaws.com/',
168+
'.',
169+
{ Ref: 'AWS::URLSuffix' },
170+
'/',
169171
{ Ref: 'Repo02AC86CF' }
170172
]]});
171173

packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@
346346
"ClusterEB0386A7": {
347347
"Type": "AWS::ECS::Cluster"
348348
},
349-
"FargateServiceTaskDefwebLogGroup71FAF541": {
350-
"Type": "AWS::Logs::LogGroup",
351-
"DeletionPolicy": "Retain",
352-
"UpdateReplacePolicy": "Retain"
353-
},
354349
"FargateServiceLBB353E155": {
355350
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
356351
"Properties": {
@@ -561,7 +556,11 @@
561556
}
562557
]
563558
},
564-
".amazonaws.com/",
559+
".",
560+
{
561+
"Ref": "AWS::URLSuffix"
562+
},
563+
"/",
565564
{
566565
"Fn::GetAtt": [
567566
"FargateServiceTaskDefwebAssetImageAdoptRepositoryCDAFD419",
@@ -659,8 +658,13 @@
659658
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C",
660659
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17"
661660
],
662-
"DeletionPolicy": "Delete",
663-
"UpdateReplacePolicy": "Delete"
661+
"UpdateReplacePolicy": "Delete",
662+
"DeletionPolicy": "Delete"
663+
},
664+
"FargateServiceTaskDefwebLogGroup71FAF541": {
665+
"Type": "AWS::Logs::LogGroup",
666+
"UpdateReplacePolicy": "Retain",
667+
"DeletionPolicy": "Retain"
664668
},
665669
"FargateServiceTaskDefExecutionRole9194820E": {
666670
"Type": "AWS::IAM::Role",
@@ -771,6 +775,7 @@
771775
"MinimumHealthyPercent": 50
772776
},
773777
"DesiredCount": 1,
778+
"HealthCheckGracePeriodSeconds": 60,
774779
"LaunchType": "FARGATE",
775780
"LoadBalancers": [
776781
{
@@ -781,7 +786,6 @@
781786
}
782787
}
783788
],
784-
"HealthCheckGracePeriodSeconds": 60,
785789
"NetworkConfiguration": {
786790
"AwsvpcConfiguration": {
787791
"AssignPublicIp": "DISABLED",
@@ -1041,4 +1045,4 @@
10411045
"Description": "Artifact hash for asset \"aws-ecs-integ/AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c/Code\""
10421046
}
10431047
}
1044-
}
1048+
}

packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.scheduled-fargate-task.lit.expected.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@
344344
}
345345
]
346346
},
347-
".amazonaws.com/",
347+
".",
348+
{
349+
"Ref": "AWS::URLSuffix"
350+
},
351+
"/",
348352
{
349353
"Fn::GetAtt": [
350354
"ScheduledFargateTaskScheduledTaskDefScheduledContainerAssetImageAdoptRepository49B45957",
@@ -437,13 +441,13 @@
437441
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C",
438442
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17"
439443
],
440-
"DeletionPolicy": "Delete",
441-
"UpdateReplacePolicy": "Delete"
444+
"UpdateReplacePolicy": "Delete",
445+
"DeletionPolicy": "Delete"
442446
},
443447
"ScheduledFargateTaskScheduledTaskDefScheduledContainerLogGroup4134B16C": {
444448
"Type": "AWS::Logs::LogGroup",
445-
"DeletionPolicy": "Retain",
446-
"UpdateReplacePolicy": "Retain"
449+
"UpdateReplacePolicy": "Retain",
450+
"DeletionPolicy": "Retain"
447451
},
448452
"ScheduledFargateTaskScheduledTaskDefExecutionRoleD37356D5": {
449453
"Type": "AWS::IAM::Role",
@@ -801,8 +805,8 @@
801805
"physicalResourceId": "awsfargateintegScheduledFargateTaskScheduledTaskDefB0AD4F70"
802806
}
803807
},
804-
"DeletionPolicy": "Delete",
805-
"UpdateReplacePolicy": "Delete"
808+
"UpdateReplacePolicy": "Delete",
809+
"DeletionPolicy": "Delete"
806810
},
807811
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": {
808812
"Type": "AWS::IAM::Role",
@@ -1123,4 +1127,4 @@
11231127
"Description": "Artifact hash for asset \"aws-fargate-integ/AWS679f53fac002430cb0da5b7982bd2287/Code\""
11241128
}
11251129
}
1126-
}
1130+
}

packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -446,37 +446,37 @@
446446
"Resource": "*"
447447
},
448448
{
449-
"Action": [
450-
"ecs:ListContainerInstances",
451-
"ecs:SubmitContainerStateChange",
452-
"ecs:SubmitTaskStateChange"
453-
],
454-
"Effect": "Allow",
455-
"Resource": {
456-
"Fn::GetAtt": [
457-
"EcsCluster97242B84",
458-
"Arn"
459-
]
449+
"Action": [
450+
"ecs:ListContainerInstances",
451+
"ecs:SubmitContainerStateChange",
452+
"ecs:SubmitTaskStateChange"
453+
],
454+
"Effect": "Allow",
455+
"Resource": {
456+
"Fn::GetAtt": [
457+
"EcsCluster97242B84",
458+
"Arn"
459+
]
460+
}
461+
},
462+
{
463+
"Action": [
464+
"ecs:UpdateContainerInstancesState",
465+
"ecs:ListTasks"
466+
],
467+
"Condition": {
468+
"ArnEquals": {
469+
"ecs:cluster": {
470+
"Fn::GetAtt": [
471+
"EcsCluster97242B84",
472+
"Arn"
473+
]
474+
}
460475
}
461476
},
462-
{
463-
"Action": [
464-
"ecs:UpdateContainerInstancesState",
465-
"ecs:ListTasks"
466-
],
467-
"Condition": {
468-
"ArnEquals": {
469-
"ecs:cluster": {
470-
"Fn::GetAtt": [
471-
"EcsCluster97242B84",
472-
"Arn"
473-
]
474-
}
475-
}
476-
},
477-
"Effect": "Allow",
478-
"Resource": "*"
479-
}
477+
"Effect": "Allow",
478+
"Resource": "*"
479+
}
480480
],
481481
"Version": "2012-10-17"
482482
},
@@ -740,7 +740,11 @@
740740
}
741741
]
742742
},
743-
".amazonaws.com/",
743+
".",
744+
{
745+
"Ref": "AWS::URLSuffix"
746+
},
747+
"/",
744748
{
745749
"Fn::GetAtt": [
746750
"TaskDefTheContainerAssetImageAdoptRepository997406C3",
@@ -832,13 +836,13 @@
832836
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C",
833837
"AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17"
834838
],
835-
"DeletionPolicy": "Delete",
836-
"UpdateReplacePolicy": "Delete"
839+
"UpdateReplacePolicy": "Delete",
840+
"DeletionPolicy": "Delete"
837841
},
838842
"TaskDefTheContainerLogGroupD94C8EF5": {
839843
"Type": "AWS::Logs::LogGroup",
840-
"DeletionPolicy": "Retain",
841-
"UpdateReplacePolicy": "Retain"
844+
"UpdateReplacePolicy": "Retain",
845+
"DeletionPolicy": "Retain"
842846
},
843847
"TaskDefExecutionRoleB4775C97": {
844848
"Type": "AWS::IAM::Role",
@@ -1215,4 +1219,4 @@
12151219
"Description": "Artifact hash for asset \"aws-ecs-integ-ecs/AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c/Code\""
12161220
}
12171221
}
1218-
}
1222+
}

0 commit comments

Comments
 (0)