Aws-lambda-dotnet: Error: S3 bucket must be in the same region as the configured region us-west-2. is in the region us-east-1.

Created on 17 Jan 2018  路  7Comments  路  Source: aws/aws-lambda-dotnet

  • I created a new project using dotnet new, with AWS Serverless WebAPI template (ASP.NET Core 2.0). This includes ValuesController and S3ProxyController sample code.
  • My primary region is us-west-2 so I did a find-replace to change the region in all .appsettings files.
  • I also ran aws configure to set my default profile Key ID, Access Key, and Region to aws-west-2.

After all this, I run dotnet lambda deploy-serverless and it's trying to use us-east-1. Is this a problem with the template or the AWS CLI?

Error: S3 bucket must be in the same region as the configured region us-west-2. is in the region us-east-1.

Most helpful comment

There is still a problem in which the S3 bucket containing your zip file with your lambda package needs to be in the same region as your lambda function is being created on. This is counter intuitive and in my opinion, awful. If we want to leverage the same template across multiple regions we need to duplicate the contents of the package across multiple buckets. They could at least accept a URL in the CodeUri property so we could use a public bucket or github for storing the package .

Seriously, this is awful. What is the use of global s3 buckets when you cannot support lambda function code update from a single s3 bucket instead of creating duplicate buckets in every region.

All 7 comments

I uploaded the serverless.template generated by the dotnet new to AWS and got the following error when trying to create a stack from it:

Error creating change set: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ProxyFunction] is invalid. 'CodeUri' is not a valid S3 Uri of the form "s3://bucket/key" with optional versionId query parameter.

It seems like something is wrong with the template. I don't have much experience with CloudFormation, still investigating.

Today I made some progress by finally understanding the error message :)

The "ProxyFunction" resource in the cloud formation template has CodeUri parameter set to empty string. Continuing investigation into why empty string is not supported there.

Apparently CodeUri can be relative, a dynamic parameter, or a static URL but never empty string.

https://github.com/awslabs/serverless-application-model/blob/master/HOWTO.md

Do you have a page where you say CodeUri needs to be replaced by something? The cheapest fix would be to include it as a parameter, then you don't need to document it.

Looks like everything worked, it was confusing because there are two S3 buckets involved, the proxy bucket and the bucket where lambda function code is uploaded. Once I created a bucket for the lambda and specified its name, and also specified a unique name for the proxy bucket that wasn't in use, the severless transform in cloud formation worked.

There is still a problem in which the S3 bucket containing your zip file with your lambda package needs to be in the same region as your lambda function is being created on. This is counter intuitive and in my opinion, awful. If we want to leverage the same template across multiple regions we need to duplicate the contents of the package across multiple buckets. They could at least accept a URL in the CodeUri property so we could use a public bucket or github for storing the package .

For that you should give the feedback to the CloudFormation team. It is beyond the scope of this repository to change CloudFormation's behavor.

There is still a problem in which the S3 bucket containing your zip file with your lambda package needs to be in the same region as your lambda function is being created on. This is counter intuitive and in my opinion, awful. If we want to leverage the same template across multiple regions we need to duplicate the contents of the package across multiple buckets. They could at least accept a URL in the CodeUri property so we could use a public bucket or github for storing the package .

Seriously, this is awful. What is the use of global s3 buckets when you cannot support lambda function code update from a single s3 bucket instead of creating duplicate buckets in every region.

Was this page helpful?
0 / 5 - 0 ratings