Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ecr): setting imageScanningConfiguration to false does nothing on existing repository #18078

Merged
merged 2 commits into from Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/@aws-cdk/aws-batch/test/integ.batch.expected.json
Expand Up @@ -1665,6 +1665,11 @@
},
"batchjobrepo4C508C51": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
Expand Down Expand Up @@ -1725,8 +1730,14 @@
"Privileged": false,
"ReadonlyRootFilesystem": false,
"ResourceRequirements": [
{ "Type": "VCPU", "Value": "1" },
{ "Type": "MEMORY", "Value": "4" }
{
"Type": "VCPU",
"Value": "1"
},
{
"Type": "MEMORY",
"Value": "4"
}
]
},
"PlatformCapabilities": [
Expand Down
Expand Up @@ -2,6 +2,11 @@
"Resources": {
"MyRepoF4F48043": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
Expand Down
Expand Up @@ -356,6 +356,11 @@
},
"MyEcrRepo767466D0": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
Expand Down
Expand Up @@ -201,6 +201,11 @@
},
"EcrRepoBB83A592": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
Expand Down
Expand Up @@ -3,6 +3,11 @@
"Resources": {
"EcsDeployRepositoryE7A569C0": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-ecr/lib/repository.ts
Expand Up @@ -508,9 +508,7 @@ export class Repository extends RepositoryBase {
// It says "Text", but they actually mean "Object".
repositoryPolicyText: Lazy.any({ produce: () => this.policyDocument }),
lifecyclePolicy: Lazy.any({ produce: () => this.renderLifecyclePolicy() }),
imageScanningConfiguration: !props.imageScanOnPush ? undefined : {
scanOnPush: true,
},
imageScanningConfiguration: props.imageScanOnPush ? { scanOnPush: true } : { scanOnPush: false },
imageTagMutability: props.imageTagMutability || undefined,
encryptionConfiguration: this.parseEncryption(props),
});
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-ecr/test/integ.basic.expected.json
Expand Up @@ -3,6 +3,9 @@
"Repo02AC86CF": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
},
"LifecyclePolicy": {
"LifecyclePolicyText": "{\"rules\":[{\"rulePriority\":1,\"selection\":{\"tagStatus\":\"any\",\"countType\":\"imageCountMoreThan\",\"countNumber\":5},\"action\":{\"type\":\"expire\"}}]}"
}
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-ecr/test/repository.test.ts
Expand Up @@ -20,6 +20,11 @@ describe('repository', () => {
Resources: {
Repo02AC86CF: {
Type: 'AWS::ECR::Repository',
Properties: {
ImageScanningConfiguration: {
ScanOnPush: false,
},
},
DeletionPolicy: 'Retain',
UpdateReplacePolicy: 'Retain',
},
Expand Down
Expand Up @@ -465,6 +465,9 @@ describe('ec2 task definition', () => {

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

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {});
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
ImageScanningConfiguration: {
ScanOnPush: false,
},
});


});
Expand Down
Expand Up @@ -356,6 +356,9 @@ describe('external task definition', () => {

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

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {});
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
ImageScanningConfiguration: {
ScanOnPush: false,
},
});


});
Expand Down