serverless: Receive "Deployment bucket is not in the same region as the lambda function" when using us-east-1

This is a Bug Report

Description

  • What went wrong?

When attempting to use a pre-existing S3 bucket in us-east-1 via the deploymentBucket configuration option, I receive an error response “Deployment bucket is not in the same region as the lambda function”.

Debugging through the Serverless code, I observed that it is attempting to match a LocationConstraint returned from the AWS SDK to the region; however, AWS Documentation states:

When the bucket’s region is US East (N. Virginia), Amazon S3 returns an empty string for the bucket’s region

Due to this, it appears the check in configureStack.js to match the bucket’s region with the specified region fails and I receive the error message.

  • What did you expect should have happened?

I should have been able to use the pre-existing bucket.

  • What was the config you used?
...
provider:
  name: aws
  runtime: nodejs4.3
  stage: dev
  region: us-east-1
  deploymentBucket: my-bucket-name
...
  • What stacktrace or error message from your provider did you see?

Deployment bucket is not in the same region as the lambda function

Additional Data

  • _Serverless Framework Version you’re using_: 1.0.2
  • _Operating System_: OSX
  • _Stack Trace_:
  • _Provider Error messages_:
  Serverless Error ---------------------------------------

     Deployment bucket is not in the same region as the lambda
     function.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

May I know why it is not allowed to use the S3 bucket from different region? Is there any reason for that?

Hi @eahefnawy are you still looking into EU - eu-west-1 issue? Do you need a hand?

BOOM! 💥 That is one nice catch @ssemyonov … I feel like we’re always on a mission to keep up with AWS inconsistencies 😄 … I’m gonna PR a quick fix today.

Thanks for reporting and investigating @briguy202 😊 … I’ve pushed a fix along with this PR and will be merged very soon. It’s a high priority!

Cheers 👼

Having it trying to run sls dev for sa-east-1. No clue on how to solve this.

I’ve got the same issue happening when using pre-existing deployment bucket in eu-west-1 region in some of AWS accounts in my company. The reason is AWS returns LocationConstraint value as EU which is one of the values for eu-west-1 according to AWS docs:

Valid Values: [ us-west-1 | us-west-2 | ca-central-1 | EU or eu-west-1 | eu-west-2 | eu-central-1 | ap-south-1 | ap-southeast-1 | ap-southeast-2 | ap-northeast-1 | ap-northeast-2 | sa-east-1 | empty string (for the US East (N. Virginia) region) | us-east-2]

This could be one-liner fix in configureStack.js similar to the fix for original issue:

if (result.LocationConstraint === 'EU') result.LocationConstraint = 'eu-west-1';

Should I raise a separate issue for this case or current one could be reopened?