I have a service I deployed into us-east-1, I would also like to deploy it to ca-central-1. It fails to deploy stating
~/p/amibackup ❯❯❯ sls deploy -v --region ca-central-1 --stage prod --aws-profile profilename master ✱
Serverless 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
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless
Your Environment Information -----------------------------
OS: linux
Node Version: 6.11.3
Serverless Version: 1.23.0
~/p/amibackup ❯❯❯
Have you tried making the service name dynamic? I’m guessing that the deployment bucket for Serverless is still in the same region, but if you change the service name it should treat it as a completely new service and you won’t have that issue.
I can not remove the deployment bucket for policy reasons, but your first suggestion worked.
Can you explain the difference between ${self:provider.region} and ${opt:region, self:provider.region} ? I read it as self:provider.region is the value I specify with --region. not sure what the opt:region part is.
Using --region doesn’t change the value of ${self:provider.region}. It’s always the value of region set in the provider section of serverless.yml. By using ${opt:region, self:provider.region} you’re telling it to use the value from the --region command line option if provided then the value for region from the provider section in your serverless.yml if it isn’t.
I have another question. Can we defaultly set the order in sls on how to read the variables.
`--region` : ${opt:region}
system environment variable: ${env:AWS_DEFAULT_REGION} or ${env:AWS_REGION}
self: ${self:provider.region}
custom: ${self:custom:region}
and more.
The AWS CLI looks for credentials and configuration settings in the following order:
Command line options – region, output format and profile can be specified as command options to override default settings.
Environment variables – AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN.
The AWS credentials file – located at ~/.aws/credentials on Linux, macOS, or Unix, or at C:\Users\USERNAME .aws\credentials on Windows. This file can contain multiple named profiles in addition to a default profile.
The CLI configuration file – typically located at ~/.aws/config on Linux, macOS, or Unix, or at C:\Users\USERNAME .aws\config on Windows. This file can contain a default profile, named profiles, and CLI specific configuration parameters for each.
Container credentials – provided by Amazon EC2 Container Service on container instances when you assign a role to your task.
Instance profile credentials – these credentials can be used on EC2 instances with an assigned instance role, and are delivered through the Amazon EC2 metadata service.