Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
briguy202 opened this issue Oct 16, 2016 · 15 comments · Fixed by #3107
Labels

Comments

@briguy202
Copy link

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.
@eahefnawy
Copy link
Member

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 👼

@doapp-ryanp
Copy link
Contributor

Is there a workaround for this one? I was hoping that omitting provider.region would get around it but no dice.

@briguy202
Copy link
Author

@doapp-ryanp, unfortunately I don't think there is other than to patch the issue or wait on #2385 which looks to be very close to completion. If you opt for patching, which is what we did, it's a one-liner change - see briguy202@750c55b.

@pmuens
Copy link
Contributor

pmuens commented Oct 19, 2016

Should be resolved with #2385 /cc @flomotlik

@ssemyonov
Copy link

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?

@eahefnawy
Copy link
Member

eahefnawy commented Jan 4, 2017

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.

@eahefnawy eahefnawy reopened this Jan 4, 2017
@pmuens pmuens added the bug label Jan 4, 2017
@ssemyonov
Copy link

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

@ssemyonov
Copy link

PR #3107 created to address EU - eu-west-1 issue.

@voiceactivity
Copy link

For some reasons this merge was lost. Having same issue with the latest sls -> 1.27.2
Can confirm that at least master lost this bit:

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

You can check this out here: https://github.com/ssemyonov/serverless/blob/master/lib/plugins/aws/deploy/lib/configureStack.js [line 33]

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

Could not locate deployment bucket. Error: Deployment bucket is not in the same region as the lambda function

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com

Your Environment Information -----------------------------
OS: darwin
Node Version: 8.9.1
Serverless Version: 1.27.2

Could you please fix it!

@HyperBrain
Copy link
Member

@voiceactivity The check is still there - in existsDeploymentBucket.js:

        const result = resultParam;
        if (result.LocationConstraint === '') result.LocationConstraint = 'us-east-1';
        if (result.LocationConstraint === 'EU') result.LocationConstraint = 'eu-west-1';
        if (result.LocationConstraint !== this.provider.getRegion()) {

https://github.com/serverless/serverless/blob/master/lib/plugins/aws/deploy/lib/existsDeploymentBucket.js#L17

It seems that you have some old code there - the configureStack file has been removed for some time now 😄

@voiceactivity
Copy link

Thanks for that. I am still getting the error. I will investigate further.

@priyaprabhakar777
Copy link

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

@max-lobur
Copy link

max-lobur commented Jul 5, 2019

Having the same issue when using profiles. Profile has us-west-2 region set, and bucket is in us-west-2, however I get Deployment bucket is not in the same region as the lambda function. AWS Env vars are not set, so I'm not sure where it takes the other region.

Setting us-west-2 in provider explicitly works, but this breaks the profiles abstraction :(

@rodrigogs
Copy link

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

@seba-i
Copy link

seba-i commented Apr 21, 2021

For the sake of trying it, commenting out the location constraint worked for my simple resource (SES templates) deploy file.

node_modules/serverless/lib/plugins/aws/deploy/lib/existsDeploymentBucket.js

  ...
  const result = resultParam;
  if (result.LocationConstraint === '') result.LocationConstraint = 'us-east-1';
  if (result.LocationConstraint === 'EU') result.LocationConstraint = 'eu-west-1';
  // if (result.LocationConstraint !== this.provider.getRegion()) {
  //   throw new ServerlessError(
  //     'Deployment bucket is not in the same region as the lambda function'
  //   );
  // }
  return BbPromise.resolve();
  ...

Buckets are global, why is this constraint necessary? Unless you've lucked out and created everything in a region where every service you'll ever need is available, its likely to cause a headache some day...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet