Skip to content

(ecr): setting imageScanOnPush to false doesn't update Repository after first being set to true #18077

@peterwoodworth

Description

@peterwoodworth

What is the problem?

Setting imageScanOnPush to false sets the property on the underlying CfnRepository to undefined

const resource = new CfnRepository(this, 'Resource', {
repositoryName: this.physicalName,
// 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,
},

This is fine when creating the Repository because the default setting is to set this to false. However, it appears this is only the default setting for creating the repository - not the default setting for updating the repository.

Reproduction Steps

First create a new ECR Repository with imageScanOnPush set to true

 const repo = new Repository(this, 'repo', {
   imageScanOnPush: true
 })

Then update that setting to false and deploy

What did you expect to happen?

ScanOnPush to be set to false in AWS console

What actually happened?

ScanOnPush is still set to true

CDK CLI Version

2.2.0

Framework Version

No response

Node.js Version

16.0.0

OS

Mac

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecrRelated to Amazon Elastic Container RegistrybugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions