Reputation: 3
When I'm going to create an S3 bucket by the Cloudformation stack it's sending me this error message: 'Exactly one of TransitionDate and TransitionInDays must be specified'. The transition in days is specified as per the code below:
Resources:
S3CreateBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "${AWS::StackName}"
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
LoggingConfiguration:
DestinationBucketName: xxxx
LogFilePrefix: !Sub "{AWS::StackName}"/
LifecycleConfiguration:
Rules:
- Id: Multipartupload
Status: 'Enabled'
AbortIncompleteMultipartUpload:
DaysAfterInitiation: 7
ExpirationInDays: 180
- Id: Glacier
Status: 'Enabled'
Transitions:
- StorageClass: GLACIER
- TransitionInDays: 90
Tags:
-
Key: Name
Value: public
VersioningConfiguration:
Status: Enabled
WebsiteConfiguration:
ErrorDocument: error.html
IndexDocument: index.html
What I can do to fix this problem?
Upvotes: 0
Views: 474
Reputation: 498
I think your format for the 'Transitions' section is incorrect. I believe this would work:
S3CreateBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "${AWS::StackName}"
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
LoggingConfiguration:
DestinationBucketName: xxxx
LogFilePrefix: !Sub "{AWS::StackName}"/
LifecycleConfiguration:
Rules:
- Id: Multipartupload
Status: 'Enabled'
AbortIncompleteMultipartUpload:
DaysAfterInitiation: 7
ExpirationInDays: 180
- Id: Glacier
Status: 'Enabled'
Transition:
StorageClass: GLACIER
TransitionInDays: 90
Tags:
-
Key: Name
Value: public
VersioningConfiguration:
Status: Enabled
WebsiteConfiguration:
ErrorDocument: error.html
IndexDocument: index.html
Note I've changed Transitions to Transition and removed the 2 separate lists https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule-transition.html
If you wanted to use Transitions as you were planning on adding more than one transition, then you would do something like below:
Transitions:
- StorageClass: String
TransitionDate: Timestamp
TransitionInDays: Integer
- StorageClass: String
TransitionDate: Timestamp
TransitionInDays: Integer
Upvotes: 1