Skip to content

Commit 78bc870

Browse files
fix(ecr): setting imageScanningConfiguration to false does nothing on existing repository (#18078)
fixes #18077 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 8c7a4ac commit 78bc870

10 files changed

Lines changed: 58 additions & 7 deletions

packages/@aws-cdk/aws-batch/test/integ.batch.expected.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,11 @@
16651665
},
16661666
"batchjobrepo4C508C51": {
16671667
"Type": "AWS::ECR::Repository",
1668+
"Properties": {
1669+
"ImageScanningConfiguration": {
1670+
"ScanOnPush": false
1671+
}
1672+
},
16681673
"UpdateReplacePolicy": "Retain",
16691674
"DeletionPolicy": "Retain"
16701675
},
@@ -1725,8 +1730,14 @@
17251730
"Privileged": false,
17261731
"ReadonlyRootFilesystem": false,
17271732
"ResourceRequirements": [
1728-
{ "Type": "VCPU", "Value": "1" },
1729-
{ "Type": "MEMORY", "Value": "4" }
1733+
{
1734+
"Type": "VCPU",
1735+
"Value": "1"
1736+
},
1737+
{
1738+
"Type": "MEMORY",
1739+
"Value": "4"
1740+
}
17301741
]
17311742
},
17321743
"PlatformCapabilities": [

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"Resources": {
33
"MyRepoF4F48043": {
44
"Type": "AWS::ECR::Repository",
5+
"Properties": {
6+
"ImageScanningConfiguration": {
7+
"ScanOnPush": false
8+
}
9+
},
510
"UpdateReplacePolicy": "Retain",
611
"DeletionPolicy": "Retain"
712
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@
356356
},
357357
"MyEcrRepo767466D0": {
358358
"Type": "AWS::ECR::Repository",
359+
"Properties": {
360+
"ImageScanningConfiguration": {
361+
"ScanOnPush": false
362+
}
363+
},
359364
"UpdateReplacePolicy": "Delete",
360365
"DeletionPolicy": "Delete"
361366
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@
201201
},
202202
"EcrRepoBB83A592": {
203203
"Type": "AWS::ECR::Repository",
204+
"Properties": {
205+
"ImageScanningConfiguration": {
206+
"ScanOnPush": false
207+
}
208+
},
204209
"UpdateReplacePolicy": "Retain",
205210
"DeletionPolicy": "Retain"
206211
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"Resources": {
44
"EcsDeployRepositoryE7A569C0": {
55
"Type": "AWS::ECR::Repository",
6+
"Properties": {
7+
"ImageScanningConfiguration": {
8+
"ScanOnPush": false
9+
}
10+
},
611
"UpdateReplacePolicy": "Retain",
712
"DeletionPolicy": "Retain"
813
},

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,7 @@ export class Repository extends RepositoryBase {
508508
// It says "Text", but they actually mean "Object".
509509
repositoryPolicyText: Lazy.any({ produce: () => this.policyDocument }),
510510
lifecyclePolicy: Lazy.any({ produce: () => this.renderLifecyclePolicy() }),
511-
imageScanningConfiguration: !props.imageScanOnPush ? undefined : {
512-
scanOnPush: true,
513-
},
511+
imageScanningConfiguration: props.imageScanOnPush ? { scanOnPush: true } : { scanOnPush: false },
514512
imageTagMutability: props.imageTagMutability || undefined,
515513
encryptionConfiguration: this.parseEncryption(props),
516514
});

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

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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ describe('repository', () => {
2020
Resources: {
2121
Repo02AC86CF: {
2222
Type: 'AWS::ECR::Repository',
23+
Properties: {
24+
ImageScanningConfiguration: {
25+
ScanOnPush: false,
26+
},
27+
},
2328
DeletionPolicy: 'Retain',
2429
UpdateReplacePolicy: 'Retain',
2530
},

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ describe('ec2 task definition', () => {
465465

466466
// THEN
467467
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
468+
ImageScanningConfiguration: {
469+
ScanOnPush: false,
470+
},
468471
LifecyclePolicy: {
469472
// eslint-disable-next-line max-len
470473
LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}',
@@ -687,7 +690,11 @@ describe('ec2 task definition', () => {
687690
});
688691

689692
// THEN
690-
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {});
693+
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
694+
ImageScanningConfiguration: {
695+
ScanOnPush: false,
696+
},
697+
});
691698

692699

693700
});

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ describe('external task definition', () => {
356356

357357
// THEN
358358
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
359+
ImageScanningConfiguration: {
360+
ScanOnPush: false,
361+
},
359362
LifecyclePolicy: {
360363
// eslint-disable-next-line max-len
361364
LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}',
@@ -587,7 +590,11 @@ describe('external task definition', () => {
587590
});
588591

589592
// THEN
590-
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {});
593+
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
594+
ImageScanningConfiguration: {
595+
ScanOnPush: false,
596+
},
597+
});
591598

592599

593600
});

0 commit comments

Comments
 (0)