Unable to add lifecycle policy to s3 bucket using serverless

PRANAV KAKADE

I want to add a lifecycle policy to my existing s3 bucket (using serverless) which deletes all the folders inside my s3 bucket.I have written the code in the serverless.yml.When I am trying to deploy my code i am getting -

Additional stack resources updated failed (UPDATE_ROLLBACK_COMPLETE).

so i checked into cloudformation stacks , i am getting message that my bucket already exists -

my_bucket_name already exists

Resource update cancelled

The following resource(s) failed to create: [my_bucket_name]

I am not sure why am i getting this , my s3_bucket code looks like this -

custom:
    additionalStacks:
      ressources:
        Resources:
          MyS3TBucket:
            Type: AWS::S3::Bucket
            Properties:
              BucketName: my_bucket
              LifecycleConfiguration:
                Rules:
                  - Status: Enabled 
                    ExpirationInDays: 30

This is not my entire s3 code but a small part of it which is required in this post. Before adding lifecycle configuration everything was working fine. Any help would be appreciated , Thank you

Marcin

As the error suggests:

my_bucket_name already exists

The bucket that you want to create already exists. If its yours, you have to delete it before you can re-create it. If not, bucket names must be globally unique. This means that maybe some other AWS user has already created a backed with the same name as yours. In this case you must ensure that the back name is absolutely unique, which is often done by adding some random postfix, e.g.:

MyS3TBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my_bucket-489d939239dd3
        LifecycleConfiguration:
          Rules:
            - Status: Enabled 
              ExpirationInDays: 30

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Trouble adding policy to s3 bucket in serverless.yaml

Does s3 lifecycle rules overwrite Deny Delete Bucket or DeleteObject policy is s3 bucket?

AWS CDK update/add lifecycle to existing S3 bucket using custom source

Elegant way to add exceptions to s3 bucket deny policy using StringNotLike condition for specific actions

How to add OriginAccessIdentity to AWS S3 Bucket Policy using troposphere

Creating S3 bucket policy in serverless - An error occurred: BucketPolicy - Invalid policy syntax

How to Add iamRoleStatements to S3 Trigger Bucket in Serverless Framework

List objects in an AWS S3 bucket (deployed using Serverless)

Add multiple S3 lifecycle rules to S3 bucket with boto3

Does AWS S3 copy to same bucket preserves TTL (Expiration date - Lifecycle Policy)?

How to get bucket policy using Airflow s3 hook

How can I add IP restrictions to s3 bucket(in the bucket Policy) already having a User restriction

Access Denied when creating S3 Bucket ACL & S3 Policy using Terraform

Unable to add XML Dom to AWS S3 bucket

Why my Serverless Lambda unable to access S3 bucket and items?

Lifecycle policy on S3 not working

Unable to create a s3 bucket with versioning using terraform

Unable to connect aws s3 bucket using boto

Unable to use aws:username to get the current IAM uername in AWS S3 bucket policy

Unable to create bucket policy for cross account write of logs in S3

Get File From S3 bucket using Serverless and Node js

How can I know what s3 bucket serverless is using for deploying?

Getting the error `Bucket name should not contain uppercase characters` when creating S3 buckets using serverless

S3 CORS policy for public bucket

AWS S3 bucket policy with condition

AWS S3 Bucket Policy is not valid

Terraform - attach policy to s3 bucket

AWS S3 Bucket Policy Whitelist

Amazon S3 Bucket Policy Public