chore(s3): add validation on required properties for lifecycle rules#31806
chore(s3): add validation on required properties for lifecycle rules#31806mergify[bot] merged 4 commits intoaws:mainfrom
Conversation
| expect(() => { | ||
| Template.fromStack(stack); |
There was a problem hiding this comment.
An error occurs in synthesize phase because the rendering is done as Lazy:
https://github.com/aws/aws-cdk/blob/v2.162.1/packages/aws-cdk-lib/aws-s3/lib/bucket.ts#L1941
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
| throw new Error('ExpiredObjectDeleteMarker cannot be specified with expiration, ExpirationDate, or TagFilters.'); | ||
| } | ||
|
|
||
| if ( |
There was a problem hiding this comment.
Thanks for the PR @go-to-k and the unit testing - I'm now wondering how we missed this validation in the first place.
This is certainly a big if statement here, but I suppose it has to be for this validation. Trying to think of other ways to format this ...
const ruleProperties = [
rule.abortIncompleteMultipartUploadAfter,
rule.expiration,
rule.expirationDate,
rule.expiredObjectDeleteMarker,
rule.noncurrentVersionExpiration,
rule.noncurrentVersionsToRetain,
rule.noncurrentVersionTransitions,
rule.transitions,
];
if (ruleProperties.every(prop => prop === undefined)) {
throw new Error('All rules for `lifecycleRules` must have at least one of the following properties: `abortIncompleteMultipartUploadAfter`, `expiration`, `expirationDate`, `expiredObjectDeleteMarker`, `noncurrentVersionExpiration`, `noncurrentVersionsToRetain`, `noncurrentVersionTransitions`, or `transitions`');
}Approving this PR 👍
|
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 # (if applicable)
Closes #.
Reason for this change
If there is a lifecycle rule that does not contain one of the specified properties, an error is raised.
A CFn message:
The properties in CFn properties:
The properties in L2 props:
Description of changes
Check whether a rule has required properties in lifecycleRules for L2 BucketProps.
Description of how you validated changes
Unit tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license