question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AWS_REGION environment variable doesn't work

See original GitHub issue

This is a Bug Report

Description

For bug reports:

  • What went wrong? I set the AWS_REGION environment variable to eu-west-1 as described in the documentation, but my API was deployed to us-east-1
  • What did you expect should have happened? The API should have been deployed to the eu-west-1 AWS region
  • What was the config you used? A config without a default region set
  • What stacktrace or error message from your provider did you see?

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.
  • If there is additional config how would it look

Similar or dependent issues:

Additional Data

  • Serverless Framework Version you’re using: 1.17.0
  • Operating System: Windows 10 (1703)
  • Stack Trace:
  • Provider Error messages:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
ozbillwangcommented, Oct 2, 2017

@horike37

Here is my workaround, AWS_DEFAULT_REGION or AWS_REGION is an environment variable, it should be set like this:

provider:
  name: aws
  runtime: nodejs6.10
  region: ${env:AWS_DEFAULT_REGION, 'us-east-1'}
4reactions
jamy015commented, Jul 19, 2017

@eahefnawy @horike37 I would think this order makes the most sense:

  1. CLI option like --region=eu-west-1
  2. setting in serverless.yml
  3. AWS_REGION env var
  4. setting in ~\.aws\config (set by the AWS CLI)
  5. if nothing to setting, set us-east-1 automatically

My reasoning behind this is that more specific options should, IMO, get more precedence:

  • the CLI option is the most specific because I’m telling serverless right there on the command line that I want to do that
  • serverless.yml is specific to the service being deployed
  • AWS_REGION is specific to serverless on the machine
  • ~\.aws\config is specific to the AWS config on the machine
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using AWS Lambda environment variables
Configuring environment variables · Open the Functions page of the Lambda console. · Choose a function. · Choose Configuration, then choose Environment variables....
Read more >
aws-cli: Exporting region env var not working? - Stack Overflow
The correct environment variable for region is AWS_DEFAULT_REGION . Refer this link for the list of environment variables.
Read more >
Working with Environment Variables in Python - Twilio
Learn how to work with environment variables to configure your Python application.
Read more >
Deploy-ECS.gitlab-ci.yml AWS_REGION variable (#219131)
I'm on gitlab.com and tried deploying to AWS ECS using the instructions for including the Deploy-ECS.gitlab-ci.yml template found here. I ended ...
Read more >
HCL2 Environment Variables - Packer - HashiCorp Discuss
I am trying to use an env var AWS_REGION but not too sure how to do it using HCL2. ... but it doesn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found