Home > Net >  Two S3 Buckets are creating when Deploying using serverless framework
Two S3 Buckets are creating when Deploying using serverless framework

Time:02-06

am trying to create S3 bucket using serverless framework. but when I deploy, it's creating two buckets one with the name I have mentioned in the severless.yml file and another bucket.

serverless.yml

service: aws-file-upload-tos3

provider:
  name: aws
  runtime: nodejs12.x
  stage: dev
  region: us-east-2
  lambdaHashingVersion: 20201221

custom:
  fileUploadBucketName: ${self:service}-${self:provider.stage}-bucket

resources:
  Resources:
    FileBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:custom.fileUploadBucketName}
        AccessControl: PublicRead

Buckets created are

enter image description here

why its creating two buckets like this

CodePudding user response:

By default, serverless framework creates a bucket with a generated name like <service name>-serverlessdeploymentbuck-1x6jug5lzfnl7 to store your service's stack state.

Each successive version of your serverless app is bundled and uploaded by sls to the deployment bucket, and deployed from there.

I think you have some control over how sls does this if you use the serverless-deployment-bucket plugin.

CodePudding user response:

By default, the Serverless Framework creates a number of things on your machine in order to deploy what you have configured in your serverles.yml. It then needs to make use of a service inside AWS called CloudFormation to actually create the resources you configured, like your S3 bucket. The best way to do this is to take the things it created on your machine and upload them to AWS to ensure that the deployment continues without interruption or issue and the best place to do that is S3.

So the Serverless Framework will always (by default) create its own S3 bucket entirely unrelated to what you configured as a location to store the files it generated on your AWS account, then point CloudFormation at it to build the things you configured to get built.

While you have some control over this deployment bucket there always needs to be one. And it is completely unrelated to the bucket you configured.

  •  Tags:  
  • Related