-
Notifications
You must be signed in to change notification settings - Fork 4k
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(s3): fail fast for s3 lifecycle configuration when ExpiredObjectDeleteMarker specified with ExpirationInDays, ExpirationDate, or TagFilters. #25841
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
8c8a858
to
9c62a47
Compare
Exemption Request: This fix is to fail fast. The integ test has no difference compared to unit test. The unit test has been added for the scenario. |
Just a random thought. Why not fix this in the type definition of Lifecycle Rule? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Just 2 minor comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests for all the combinations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add different combinations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@corymhall Could you help review this PR?
if ((rule.expiredObjectDeleteMarker != null && rule.expiredObjectDeleteMarker != undefined) | ||
&& (rule.expiration || rule.expirationDate || self.parseTagFilters(rule.tagFilters))) { | ||
// ExpiredObjectDeleteMarker cannot be specified with ExpirationInDays, ExpirationDate, or TagFilters. | ||
throw new Error('ExpiredObjectDeleteMarker cannot be specified with expiration, ExpirationDate, or TagFilters.'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ((rule.expiredObjectDeleteMarker != null && rule.expiredObjectDeleteMarker != undefined) | |
&& (rule.expiration || rule.expirationDate || self.parseTagFilters(rule.tagFilters))) { | |
// ExpiredObjectDeleteMarker cannot be specified with ExpirationInDays, ExpirationDate, or TagFilters. | |
throw new Error('ExpiredObjectDeleteMarker cannot be specified with expiration, ExpirationDate, or TagFilters.'); | |
} | |
if ((rule.expiredObjectDeleteMarker) | |
&& (rule.expiration || rule.expirationDate || this.parseTagFilters(rule.tagFilters))) { | |
// ExpiredObjectDeleteMarker cannot be specified with ExpirationInDays, ExpirationDate, or TagFilters. | |
throw new Error('ExpiredObjectDeleteMarker cannot be specified with expiration, ExpirationDate, or TagFilters.'); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I do not use the "if ((rule.expiredObjectDeleteMarker))" is the type of "expiredObjectDeleteMarker" is boolean. If its value is false, the validation here will pass without error(not work). I assume "false" could also not be specified with ExpirationInDays, ExpirationDate, or TagFilter according to public doc.
See if it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, the "this.parseTagFilters(rule.tagFilters)" will not compile, and there is same "self.parseTagFilters(rule.tagFilters)" usage at line 2112/2117. My change is to stay consistent with existing code.
See if it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have update the code for "if ((rule.expiredObjectDeleteMarker))" as suggested. Based on local integration test, the "false" of expiredObjectDeleteMarker can be specified together with ExpirationInDays, ExpirationDate, or TagFilter.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
…eleteMarker specified with ExpirationInDays, ExpirationDate, or TagFilters.
9c62a47
to
a43967a
Compare
I am not sure if we can do this in the type definition of Lifecycle Rule, because there is complex validaiton logic. We can easily do this when Lifecycle rule gets initialized and the current code shall be the only place to initialize the Lifecycle rule. See if it makes sense to you. |
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). |
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). |
Closes #25824.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license