feat(ecr): Add emptyOnDelete CloudFormation property to Repository L2 construct#28233
feat(ecr): Add emptyOnDelete CloudFormation property to Repository L2 construct#28233mergify[bot] merged 17 commits intoaws:mainfrom
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
efa45be to
161767a
Compare
161767a to
5c3ee91
Compare
91a08b1 to
04296e6
Compare
lpizzinidev
left a comment
There was a problem hiding this comment.
Thanks 👍
I left you some comments for some minor adjustments.
| imageScanningConfiguration: props.imageScanOnPush !== undefined ? { scanOnPush: props.imageScanOnPush } : undefined, | ||
| imageTagMutability: props.imageTagMutability || undefined, | ||
| encryptionConfiguration: this.parseEncryption(props), | ||
| emptyOnDelete: props.emptyOnDelete, |
There was a problem hiding this comment.
We should ignore autoDeleteImages if emptyOnDelete is set here:
if (props.emptyOnDelete === undefined && props.autoDeleteImages) {
(I think that setting emptyOnDelete = false should override autoDeleteImages = true, but feel free to comment on this).
Also:
- This will need some extra unit tests
- Does
emptyOnDelete = truerequiresremovalPolicy === RemovalPolicy.DESTROY? I wasn't able to find documentation on this
There was a problem hiding this comment.
- I'm fine with only using
autoDeleteImagesifemptyOnDeleteisundefined. emptyOnDelete = truedoes not requireremovalPolicy === RemovalPolicy.DESTROY
Made the change and added tests, please review 🙂
| emptyOnDelete: true, | ||
| }); | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Don't you think it's better to remove autoDeleteImages from the readme entirely? I've already marked it as deprecated in the JSDoc.
| emptyOnDelete: true, | ||
| }); | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Don't you think it's better to remove autoDeleteImages from the readme entirely? I've already marked it as deprecated in the JSDoc.
lpizzinidev
left a comment
There was a problem hiding this comment.
Can you please provide documentation for
emptyOnDelete = true does not require removalPolicy === RemovalPolicy.DESTROY
?
|
|
||
| ```ts | ||
| const repository = new ecr.Repository(this, 'MyTempRepo', { | ||
| removalPolicy: RemovalPolicy.DESTROY, |
There was a problem hiding this comment.
| removalPolicy: RemovalPolicy.DESTROY, |
Unnecessary.
Actually I misspoke. I was testing this out with JSON CloudFormation when I should have been testing it with CDK. |
lpizzinidev
left a comment
There was a problem hiding this comment.
Thanks!
I think we're just missing one validation and we'll be good to go.
| }); | ||
|
|
||
| if (props.autoDeleteImages) { | ||
| if (props.emptyOnDelete === undefined && props.autoDeleteImages) { |
There was a problem hiding this comment.
Given #28233 (comment).
We should validate for emptyOnDelete as well:
if (props.emptyOnDelete) {
if (props.removalPolicy !== RemovalPolicy.DESTROY) {
throw new Error('Cannot use \'emptyOnDelete\' property on a repository without setting removal policy to \'DESTROY\'.');
}
}
if (props.emptyOnDelete === undefined && props.autoDeleteImages) {
...
}With a related unit test for coverage.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Pull request has been modified.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Added
emptyOnDeleteprop to the ecrRepositoryconstruct.emptyOndeleteis supported by CloudFormationSee here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-emptyondelete
I've also deprecated the
autoDeleteImagesprop that deployed a custom resource. According to #24572 this was added before CloudFormation added theEmptyOnDeleteproperty here aws-cloudformation/cloudformation-coverage-roadmap#515Closes #28196
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license