Rayiez
Rayiez

Reputation: 1599

How to add a new lifecycle rule to existing s3 bucket using serverless framework

I have a s3 bucket.

I am using serverless to create a lambda function to read from s3.

https://serverless.com/

Everything works very well.

I want to add a lifecycle rule to this s3 bucket to delete files from s3 after few days using the serverless framework.

How can this be done in serverless.yml file ?

Upvotes: 1

Views: 2696

Answers (1)

You can follow the aws documentation to configure the life cycle rule for s3 :

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule.html

ex in YAML format :

      # configure object lifecyle
      LifecycleConfiguration:
        Rules:
          -
            ExpirationInDays: 30
            Prefix: '/'
            Status: Enabled
    

Upvotes: 3

Related Questions