-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(s3): add validation for lifecycle rule transitions #33731
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
Conversation
…tly one of transitionDate or transitionAfter is specified Fixes aws#22103 This change adds validation during synthesis to ensure that exactly one of transitionDate or transitionAfter is specified in S3 bucket lifecycle rule transitions. Previously, this validation was only performed during deployment, leading to failed deployments when neither or both properties were specified.
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.
(This review is outdated)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #33731 +/- ##
=======================================
Coverage 82.38% 82.38%
=======================================
Files 120 120
Lines 6937 6937
Branches 1170 1170
=======================================
Hits 5715 5715
Misses 1119 1119
Partials 103 103
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| // Validate transitions: exactly one of transitionDate or transitionAfter must be specified | ||
| if (rule.transitions) { |
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.
nit: It will be good to update the README with the correct example here
…er must be specified Updates the README.md to make it clear that exactly one of transitionDate or transitionAfter must be specified in lifecycle rule transitions.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Exemption Request: This change adds validation during synthesis to ensure that exactly one of transitionDate or transitionAfter is specified in S3 bucket lifecycle rule transitions. Previously, this validation was only performed during deployment, leading to failed deployments when neither or both properties were specified. |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
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). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue #22103
Closes #22103.
Reason for this change
When configuring S3 bucket lifecycle rules with transitions, CloudFormation requires exactly one of
TransitionDateorTransitionInDaysto be specified. However, the CDK currently allows configurations where neither or both properties are specified, which leads to deployment failures. This change adds validation during synthesis to catch these invalid configurations earlier in the development process.Description of changes
This change adds validation during synthesis to ensure that exactly one of transitionDate or transitionAfter is specified in S3 bucket lifecycle rule transitions. Previously, this validation was only performed during deployment, leading to failed deployments when neither or both properties were specified.
The validation is added to the
parseLifecycleRulefunction in the S3 bucket implementation, which checks each transition in the lifecycle rules.Describe any new or updated permissions being added
No new or updated IAM permissions are required for this change. This is purely a validation improvement in the CDK synthesis process.
Description of how you validated changes
Added two unit tests to verify the validation:
transitionDatenortransitionAfteris specifiedtransitionDateandtransitionAfterare specifiedAlso ran integration tests to ensure that the change doesn't affect existing valid configurations. No snapshots were updated, confirming that the change only adds validation and doesn't modify the CloudFormation output for valid configurations.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license