Mohan Aravind
Mohan Aravind

Reputation: 121

Setting Lifecycle configuration for S3 Buckets in YAML file

I'm trying to set a Life cycle configuration for my S3 buckets to expire after 90 days. However, I'm getting an error saying "Property Status cannot be empty" when pushing my CFT stack.

I tried setting a lifestyle config, and putting the expiration in days onto that, but it seems to be failing.

AWSTemplateFormatVersion: '2010-09-09'
Description: Creates S3 Bucket

Resources:
 TestBucket:
 Type: AWS::S3::Bucket
 Properties:
   BucketName: !Sub "${AWS::StackName}-test"
   AccessControl: Private
   LifecycleConfiguration:
    Rules:
    - Id: DeleteContentAfter90Days
      Prefix: ''
      Status: Enabled
      ExpirationInDays: '90'

I'm getting "Property status cannot be empty" and an update rollback when I check my status in the console.

Upvotes: 10

Views: 16030

Answers (3)

tjay
tjay

Reputation: 21

Cloudformation can't take null values, remove this line - Prefix: ''

Upvotes: 2

Efi gazarov
Efi gazarov

Reputation: 171

Status: 'Enabled'

Status should be string value as stated in the documentation

Here is a working example of LifecycleConfiguration:

LifecycleConfiguration:
    Rules:
      - Id: DeleteContentAfter1Day
        Status: 'Enabled'
        ExpirationInDays: 1

Upvotes: 16

user3407348
user3407348

Reputation: 51

ExpirationInDays should be a number, not a string

Upvotes: 5

Related Questions