shou2017.com
JP

AWS SDK missing region in config

Tue Feb 25, 2020
Sat Aug 10, 2024
AWS

When I tried to display logged-in user information with Amazon Cognito using AWS SDK for JavaScript, I encountered this error:

{ [ConfigError: Missing region in config]
message: 'Missing region in config',
code: 'ConfigError',

I was frustrated because I had properly set the region in my ~/.aws/credentials file.

# ~/.aws/credentials

[default]
aws_access_key_id = xxxxxx
aws_secret_access_key = yyyyy
region = ap-northeast-1

I don’t know the correct solution yet, but I worked around the issue by updating the config:

var AWS = require("aws-sdk");
AWS.config.update({region:'ap-northeast-1'});
See Also