-
Couldn't load subscription status.
- Fork 4.3k
Description
Describe the bug
Synthed buckets can end up with an invalid lifecycle configuration which fails to be applied by CFN when adding the expiredObjectDeleteMarker configuration.
For example, according to the CFN docs for ExpiredObjectDeleteMarker:
This cannot be specified with
ExpirationInDays,ExpirationDate, orTagFilters.
However, if the developer sets expire and expiredObjectDeleteMarker, CDK synths the code with no errors.
Expected Behavior
An invalid lifecycle configuration should fail to synth.
Current Behavior
When an invalid lifecycle configuration is specified, CDK synths the artifacts without raising any warning or errors. The error only occurs when applying the template in CFN. You get this fantastically cryptic error in the CFN logs, and the stack rolls back:
The XML you provided was not well-formed or did not validate against our published schema (Service: Amazon S3; Status Code: 400; Error Code: MalformedXML;)
Reproduction Steps
This code would generate a template that would fail to be applied in CFN:
new s3.Bucket(this, 'bucket', {
lifecycleRules: [
{
enabled: true,
expiration: Duration.days(14),
noncurrentVersionExpiration: Duration.days(7),
abortIncompleteMultipartUploadAfter: Duration.days(1),
expiredObjectDeleteMarker: true,
},
],
});Possible Solution
If the user adds an invalid combination of lifecycle configurations, we could do any of these:
- prominently warn the user that the configuration will fail in CFN
- just fail the build completely
Additional Information/Context
No response
CDK CLI Version
2.79.1
Framework Version
No response
Node.js Version
19.1.0
OS
Linux
Language
Typescript
Language Version
4.9.5
Other information
No response