ConfigError: Missing region in config
TL;DR — The AWS SDK doesn't know which region to talk to. Set it explicitly on the client (new DynamoDBClient({ region: 'us-east-1' })), or via the AWS_REGION environment variable, or in ~/.aws/config.
What it means
ConfigError: Missing region in configEvery DynamoDB endpoint is regional, so the SDK must resolve a region before it can send a request. When none of its configuration sources supplies one, it throws this before any network call.
Why it happens
- No region passed to the client and no
AWS_REGION/AWS_DEFAULT_REGIONin the environment. - No default region in
~/.aws/configfor the active profile. - Running in a context without instance/role metadata (a local script, some CI runners) where the SDK can't infer a region.
- A typo in the env var name (
AWS_REGIONS,REGION).
How to fix it (any one of these)
- Set it on the client (most explicit):
import {DynamoDBClient} from '@aws-sdk/client-dynamodb'; const client = new DynamoDBClient({region: 'us-east-1'}); - Environment variable:
export AWS_REGION=us-east-1 - AWS config file (
~/.aws/config):[default] region = us-east-1 - DynamoDB Local? It still needs a region string (any value) plus an
endpoint:const client = new DynamoDBClient({region: 'local', endpoint: 'http://localhost:8000'});
Related errors
- The security token is invalid
- ResourceNotFoundException — often a region mismatch once a region is set.
- Unable to start DynamoDB Local process