Skip to content

Commit 2ff3143

Browse files
fix(ecr): scanOnPush not supported in certain regions (#19940)
fixes #19918 ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 987558c commit 2ff3143

File tree

16 files changed

+18
-81
lines changed

16 files changed

+18
-81
lines changed

packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/batch-stack.template.json

-5
Original file line numberDiff line numberDiff line change
@@ -1362,11 +1362,6 @@
13621362
},
13631363
"batchjobrepo4C508C51": {
13641364
"Type": "AWS::ECR::Repository",
1365-
"Properties": {
1366-
"ImageScanningConfiguration": {
1367-
"ScanOnPush": false
1368-
}
1369-
},
13701365
"UpdateReplacePolicy": "Retain",
13711366
"DeletionPolicy": "Retain"
13721367
},

packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/tree.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -1601,11 +1601,7 @@
16011601
"path": "batch-stack/batch-job-repo/Resource",
16021602
"attributes": {
16031603
"aws:cdk:cloudformation:type": "AWS::ECR::Repository",
1604-
"aws:cdk:cloudformation:props": {
1605-
"imageScanningConfiguration": {
1606-
"scanOnPush": false
1607-
}
1608-
}
1604+
"aws:cdk:cloudformation:props": {}
16091605
},
16101606
"constructInfo": {
16111607
"fqn": "@aws-cdk/aws-ecr.CfnRepository",

packages/@aws-cdk/aws-codebuild/test/ecr.lit.integ.snapshot/test-codebuild-docker-asset.template.json

-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
"Resources": {
33
"MyRepoF4F48043": {
44
"Type": "AWS::ECR::Repository",
5-
"Properties": {
6-
"ImageScanningConfiguration": {
7-
"ScanOnPush": false
8-
}
9-
},
105
"UpdateReplacePolicy": "Retain",
116
"DeletionPolicy": "Retain"
127
},

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
"path": "test-codebuild-docker-asset/MyRepo/Resource",
2626
"attributes": {
2727
"aws:cdk:cloudformation:type": "AWS::ECR::Repository",
28-
"aws:cdk:cloudformation:props": {
29-
"imageScanningConfiguration": {
30-
"scanOnPush": false
31-
}
32-
}
28+
"aws:cdk:cloudformation:props": {}
3329
},
3430
"constructInfo": {
3531
"fqn": "@aws-cdk/aws-ecr.CfnRepository",

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-ecr-source.integ.snapshot/aws-cdk-codepipeline-ecr-source.template.json

-5
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,6 @@
354354
},
355355
"MyEcrRepo767466D0": {
356356
"Type": "AWS::ECR::Repository",
357-
"Properties": {
358-
"ImageScanningConfiguration": {
359-
"ScanOnPush": false
360-
}
361-
},
362357
"UpdateReplacePolicy": "Delete",
363358
"DeletionPolicy": "Delete"
364359
},

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-ecr-source.integ.snapshot/tree.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,7 @@
574574
"path": "aws-cdk-codepipeline-ecr-source/MyEcrRepo/Resource",
575575
"attributes": {
576576
"aws:cdk:cloudformation:type": "AWS::ECR::Repository",
577-
"aws:cdk:cloudformation:props": {
578-
"imageScanningConfiguration": {
579-
"scanOnPush": false
580-
}
581-
}
577+
"aws:cdk:cloudformation:props": {}
582578
},
583579
"constructInfo": {
584580
"fqn": "@aws-cdk/aws-ecr.CfnRepository",

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

-5
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@
215215
},
216216
"EcrRepoBB83A592": {
217217
"Type": "AWS::ECR::Repository",
218-
"Properties": {
219-
"ImageScanningConfiguration": {
220-
"ScanOnPush": false
221-
}
222-
},
223218
"UpdateReplacePolicy": "Retain",
224219
"DeletionPolicy": "Retain"
225220
},

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,7 @@
404404
"path": "aws-cdk-codepipeline-ecs-deploy/EcrRepo/Resource",
405405
"attributes": {
406406
"aws:cdk:cloudformation:type": "AWS::ECR::Repository",
407-
"aws:cdk:cloudformation:props": {
408-
"imageScanningConfiguration": {
409-
"scanOnPush": false
410-
}
411-
}
407+
"aws:cdk:cloudformation:props": {}
412408
},
413409
"constructInfo": {
414410
"fqn": "@aws-cdk/aws-ecr.CfnRepository",

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-ecs-separate-source.lit.integ.snapshot/aws-cdk-pipeline-ecs-separate-sources.template.json

-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
"Resources": {
33
"EcsDeployRepositoryE7A569C0": {
44
"Type": "AWS::ECR::Repository",
5-
"Properties": {
6-
"ImageScanningConfiguration": {
7-
"ScanOnPush": false
8-
}
9-
},
105
"UpdateReplacePolicy": "Retain",
116
"DeletionPolicy": "Retain"
127
},

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-ecs-separate-source.lit.integ.snapshot/tree.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
"path": "aws-cdk-pipeline-ecs-separate-sources/EcsDeployRepository/Resource",
2626
"attributes": {
2727
"aws:cdk:cloudformation:type": "AWS::ECR::Repository",
28-
"aws:cdk:cloudformation:props": {
29-
"imageScanningConfiguration": {
30-
"scanOnPush": false
31-
}
32-
}
28+
"aws:cdk:cloudformation:props": {}
3329
},
3430
"constructInfo": {
3531
"fqn": "@aws-cdk/aws-ecr.CfnRepository",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ export class Repository extends RepositoryBase {
534534
// It says "Text", but they actually mean "Object".
535535
repositoryPolicyText: Lazy.any({ produce: () => this.policyDocument }),
536536
lifecyclePolicy: Lazy.any({ produce: () => this.renderLifecyclePolicy() }),
537-
imageScanningConfiguration: props.imageScanOnPush ? { scanOnPush: true } : { scanOnPush: false },
537+
imageScanningConfiguration: props.imageScanOnPush !== undefined ? { scanOnPush: props.imageScanOnPush } : undefined,
538538
imageTagMutability: props.imageTagMutability || undefined,
539539
encryptionConfiguration: this.parseEncryption(props),
540540
});

packages/@aws-cdk/aws-ecr/test/basic.integ.snapshot/aws-ecr-integ-stack.template.json

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
"Repo02AC86CF": {
44
"Type": "AWS::ECR::Repository",
55
"Properties": {
6-
"ImageScanningConfiguration": {
7-
"ScanOnPush": false
8-
},
96
"LifecyclePolicy": {
107
"LifecyclePolicyText": "{\"rules\":[{\"rulePriority\":1,\"selection\":{\"tagStatus\":\"any\",\"countType\":\"imageCountMoreThan\",\"countNumber\":5},\"action\":{\"type\":\"expire\"}}]}"
118
}

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

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
"attributes": {
2727
"aws:cdk:cloudformation:type": "AWS::ECR::Repository",
2828
"aws:cdk:cloudformation:props": {
29-
"imageScanningConfiguration": {
30-
"scanOnPush": false
31-
},
3229
"lifecyclePolicy": {
3330
"lifecyclePolicyText": "{\"rules\":[{\"rulePriority\":1,\"selection\":{\"tagStatus\":\"any\",\"countType\":\"imageCountMoreThan\",\"countNumber\":5},\"action\":{\"type\":\"expire\"}}]}"
3431
}

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

+10-8
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ describe('repository', () => {
2020
Resources: {
2121
Repo02AC86CF: {
2222
Type: 'AWS::ECR::Repository',
23-
Properties: {
24-
ImageScanningConfiguration: {
25-
ScanOnPush: false,
26-
},
27-
},
2823
DeletionPolicy: 'Retain',
2924
UpdateReplacePolicy: 'Retain',
3025
},
@@ -34,13 +29,20 @@ describe('repository', () => {
3429

3530
test('repository creation with imageScanOnPush', () => {
3631
// GIVEN
37-
const stack = new cdk.Stack();
32+
const noScanStack = new cdk.Stack();
33+
const scanStack = new cdk.Stack();
3834

3935
// WHEN
40-
new ecr.Repository(stack, 'Repo', { imageScanOnPush: true });
36+
new ecr.Repository(noScanStack, 'NoScanRepo', { imageScanOnPush: false });
37+
new ecr.Repository(scanStack, 'ScanRepo', { imageScanOnPush: true });
4138

4239
// THEN
43-
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
40+
Template.fromStack(noScanStack).hasResourceProperties('AWS::ECR::Repository', {
41+
ImageScanningConfiguration: {
42+
ScanOnPush: false,
43+
},
44+
});
45+
Template.fromStack(scanStack).hasResourceProperties('AWS::ECR::Repository', {
4446
ImageScanningConfiguration: {
4547
ScanOnPush: true,
4648
},

packages/@aws-cdk/aws-ecs/test/ec2/ec2-task-definition.test.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,6 @@ describe('ec2 task definition', () => {
451451

452452
// THEN
453453
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
454-
ImageScanningConfiguration: {
455-
ScanOnPush: false,
456-
},
457454
LifecyclePolicy: {
458455
// eslint-disable-next-line max-len
459456
LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}',
@@ -674,11 +671,7 @@ describe('ec2 task definition', () => {
674671
});
675672

676673
// THEN
677-
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
678-
ImageScanningConfiguration: {
679-
ScanOnPush: false,
680-
},
681-
});
674+
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {});
682675
});
683676

684677
test('warns when setting containers from ECR repository using fromRegistry method', () => {

packages/@aws-cdk/aws-ecs/test/external/external-task-definition.test.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,6 @@ describe('external task definition', () => {
350350

351351
// THEN
352352
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
353-
ImageScanningConfiguration: {
354-
ScanOnPush: false,
355-
},
356353
LifecyclePolicy: {
357354
// eslint-disable-next-line max-len
358355
LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}',
@@ -578,11 +575,7 @@ describe('external task definition', () => {
578575
});
579576

580577
// THEN
581-
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
582-
ImageScanningConfiguration: {
583-
ScanOnPush: false,
584-
},
585-
});
578+
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {});
586579
});
587580

588581
test('warns when setting containers from ECR repository using fromRegistry method', () => {

0 commit comments

Comments
 (0)