Open
Description
What is the problem?
I created the lifecycle rule shown below and assigned it to an S3 bucket:
LifecycleRule deleteAfterThirtyDays = LifecycleRule.builder()
.id("deleteAtThirtyDays")
.abortIncompleteMultipartUploadAfter(Duration.days(1))
.expiration(Duration.days(30))
.expiredObjectDeleteMarker(true)
.enabled(true)
.build();
This lifecycle rule is invalid, because, during deployment, the following cryptic error is returned from the S3 service:
The XML you provided was not well-formed or did not validate against our published schema
This was fixed after modifying the lifecyle rule to:
LifecycleRule deleteAfterThirtyDays = LifecycleRule.builder()
.expiration(Duration.days(30))
.enabled(true)
.build();
Reproduction Steps
public class BootstrapStack extends Stack {
public BootstrapStack(final Construct scope, final String id) {
this(scope, id, null);
}
public BootstrapStack(final Construct scope, final String id, final StackProps props) {
super(scope, id, props);
LifecycleRule deleteAfterThirtyDays = LifecycleRule.builder()
.id("deleteAtThirtyDays")
.abortIncompleteMultipartUploadAfter(Duration.days(1))
.expiration(Duration.days(30))
.expiredObjectDeleteMarker(true)
.enabled(true)
.build();
Bucket loggingBucket = Bucket.Builder.create(this, "LoggingBucket")
.bucketName(Fn.sub("com.acme.myapp.logs.${AWS::AccountId}"))
.blockPublicAccess(BlockPublicAccess.BLOCK_ALL)
.encryption(BucketEncryption.S3_MANAGED)
.lifecycleRules(Collections.singletonList(deleteAfterThirtyDays))
.removalPolicy(RemovalPolicy.RETAIN)
.build();
}
}
What did you expect to happen?
I would expect the build()
call in the LifecycleRuleBuilder to detect an invalid combination of parameters and to throw a clear error during the synth phase, otherwise I do not see how CDK is any more helpful than yaml.
What actually happened?
During deployment, the following cryptic error is returned from the S3 service:
The XML you provided was not well-formed or did not validate against our published schema
CDK CLI Version
2.12.0 (build c9786db)
Framework Version
v2
Node.js Version
v14.17.1
OS
Windows 10 Enterprise
Language
Java
Language Version
Coretto 11.0.11.9
Other information
No response