env.dev

AWS_REGION

The AWS region for SDK operations, taking precedence over AWS_DEFAULT_REGION when both are set. Used by all AWS SDKs to determine the service endpoint. This is the recommended environment variable for specifying region in application code.

Last updated:

AWS_REGION tells the AWS SDKs and CLI which regional endpoint to send requests to — us-east-1, eu-west-1, ap-southeast-2, and so on. It is the recommended way to set region in application code, and it takes precedence over the older AWS_DEFAULT_REGION when both are present. Inside Lambda and other AWS compute, AWS_REGION is set for you automatically and reflects where the function runs. Most 'works in one account, fails in another' issues trace back to region: an S3 bucket or DynamoDB table only exists in the region you created it in.

Provider
AWS
Category
configuration
Set by
Set via environment variable or application configuration
Example
eu-west-1
Gotcha: us-east-1 is special: IAM, CloudFront, Route 53, and a few global services only have endpoints there, and some APIs (like requesting an ACM certificate for CloudFront) must run in us-east-1 regardless of AWS_REGION. If a global-service call fails in another region, that is usually why.

How to set AWS_REGION

bash

export AWS_REGION=eu-west-1
aws s3 ls

Node.js SDK v3

import { S3Client } from '@aws-sdk/client-s3';
// reads AWS_REGION from the environment automatically
const s3 = new S3Client({});

Docker

ENV AWS_REGION=eu-west-1

Frequently Asked Questions

Do I need to set AWS_REGION inside AWS Lambda?

No. Lambda sets AWS_REGION automatically to the region the function runs in, and the SDK picks it up. You only set it yourself when running locally, in containers outside AWS, or to target a region different from the default.

Was this helpful?

Stay up to date

Get notified about new guides, tools, and cheatsheets.

Browse all 242 environment variables →