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 config

Every 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_REGION in the environment.
  • No default region in ~/.aws/config for 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)

  1. Set it on the client (most explicit):
    import {DynamoDBClient} from '@aws-sdk/client-dynamodb';
    const client = new DynamoDBClient({region: 'us-east-1'});
  2. Environment variable:
    export AWS_REGION=us-east-1
  3. AWS config file (~/.aws/config):
    [default]
    region = us-east-1
  4. DynamoDB Local? It still needs a region string (any value) plus an endpoint:
    const client = new DynamoDBClient({region: 'local', endpoint: 'http://localhost:8000'});

不必透過主控台就能操作 DynamoDB

DynoTable 是一款快速的 DynamoDB 桌面用戶端 — 瀏覽表格、執行 SQL 風格的查詢,並在本機編輯項目。