Can't create an s3 bucket

I’m trying to create an s3 bucket. I’ve build a few serverless templates in the past, but this is the first time I’ve tried to create a bucket. Simple yaml below

service: aws-ses-forwarder
frameworkVersion: '2'

provider:
  name: aws
  runtime: nodejs12.x
  lambdaHashingVersion: 20201221

custom:
  BucketName:
    Name: ses-forwarder    

functions:
  hello:
    handler: handler.hello

resources:
  Resources:
    MYSESForwardBucket:
      Type: 'AWS::S3::Bucket'
      Properties:
        BucketName: 'mycoolbucket'

Sort of followed this examples/serverless.yml at master · serverless/examples · GitHub

Here is the error.
% serverless --profile tcdev --stage dev deploy -v
Serverless: Packaging service…
Serverless: Excluding development dependencies…
Serverless: Uploading CloudFormation file to S3…
Serverless: Uploading artifacts…
Serverless: Uploading service aws-ses-forwarder.zip file to S3 (392 B)…
Serverless: Validating template…
Serverless: Updating Stack…
Serverless: Checking Stack update progress…
CloudFormation - UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - aws-ses-forwarder-dev
CloudFormation - CREATE_IN_PROGRESS - AWS::S3::Bucket - MYSESForwardBucket
CloudFormation - CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - CREATE_IN_PROGRESS - AWS::Logs::LogGroup - HelloLogGroup
CloudFormation - CREATE_FAILED - AWS::S3::Bucket - MYSESForwardBucket
CloudFormation - CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - CREATE_FAILED - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - CREATE_FAILED - AWS::Logs::LogGroup - HelloLogGroup
CloudFormation - UPDATE_ROLLBACK_IN_PROGRESS - AWS::CloudFormation::Stack - aws-ses-forwarder-dev
CloudFormation - UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - aws-ses-forwarder-dev
CloudFormation - DELETE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - DELETE_COMPLETE - AWS::S3::Bucket - MYSESForwardBucket
CloudFormation - DELETE_COMPLETE - AWS::Logs::LogGroup - HelloLogGroup
CloudFormation - DELETE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecution
CloudFormation - UPDATE_ROLLBACK_COMPLETE - AWS::CloudFormation::Stack - aws-ses-forwarder-dev
Serverless: Operation failed!
Serverless:

Serverless Error ---------------------------------------

An error occurred: MYSESForwardBucket - mycoolbucket already exists.

Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.4.0
Framework Version: 2.18.0 (standalone)
Plugin Version: 4.4.2
SDK Version: 2.3.2
Components Version: 3.4.5

No bucket with that name exists. I’ve changed the bucket name. I’ve removed the quotes. Any suggestions?

Blockquote

Not sure why, but the custom section seems to override whatever name I provide in the resource section. This works

service: aws-ses-forwarder
frameworkVersion: '2'

provider:
  name: aws
  runtime: nodejs12.x
  lambdaHashingVersion: 20201221
  stage: dev

functions:
  hello:
    handler: handler.hello

resources:
  Resources:
    S3Assets:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:service}-${self:provider.stage}-assets

Hello, in your first example, are you sure that no such bucket with mycoolbucket name exists? Seems like a pretty plausible name and Bucket names have to unique globally.

1 Like

Keep in mind that bucket names must be globally unique. So even if YOU don’t already have a bucket with that name, somebody else probably does.

Update your template to make the name unique in some way, like {yourname}-mycoolbucket and you may have better luck.

That could very well be. Thanks for pointing that out.

1 Like