S3 create bucket fails

Viewed 8063

I'm trying to create a serverless project which deploys a CloudFormation and as a part of that it tries to create an S3 bucket. But this fails due to following error:

15:23:25 UTC+0550   CREATE_FAILED       AWS::S3::Bucket ServerlessDeploymentBucket  API: s3:CreateBucket Access Denied
15:23:24 UTC+0550   CREATE_IN_PROGRESS  AWS::S3::Bucket ServerlessDeploymentBucket  

I've tried to create an S3 bucket with command aws s3api create-bucket --bucket my-bucket --region us-west-2 which successfully creates the bucket. I'm not sure why I'm getting access denied while creating the S3 bucket via serverless. What could be the issue here?

Here's my serverless.yml file

service: auth-service-gs

provider:
  name: aws
  runtime: python2.7
  stage: dev2-gs-1
  region: us-west-2
  profile: mfa
  environment:
    DB_HOST: "DB_HOST"
    DB_USER: "root"
    DB_PASS: "<password>"
    LOG_LEVEL: "DEBUG"


functions:
  login:
    handler: handler.login
    events:
       - http:
           path: /api/v1/login
           method: post
           cors: true

I deploy the service using $serverless deploy Also, content of ~/.aws/credentials

[mfa]
aws_access_key_id = <ACESS_KEY>
aws_secret_access_key = <SECRET_KEY>
aws_session_token = <SESSION ID>

Which I got by running

$ aws sts get-session-token --serial-number arn:aws:iam::<number>:mfa/<username> --token-code 123456

1 Answers
Related