Error: AWS DynamoDB CredentialsError: Missing credentials in config

Answered by Rafal Wilinski
Solution
If you're seeing following error when using AWS SDK or CLI:
Missing credentials in the config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1or this:
{
[CredentialsError: Missing credentials in config]
message: 'Missing credentials in config',
code: 'CredentialsError'
}
It means that something is wrong with your AWS Credentials and this is not DynamoDB specific error. There are two main ways to fix this:Using AWS profiles (the recommended way)
You should use this method when dealing with problems on your computer.
AWS SDK and CLI supports usage of named profiles. They enable working with multiple AWS profiles with ease - simply pass --profile
You can configure AWS Profiles using command aws configure or by manipulating files ~/.aws/config and ~/.aws/credentials directly. Make sure they are following this format:
~/.aws/credentials (on Linux and Mac), on Windows %USERPROFILE%\.aws\credentials file:
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
~/.aws/config (on Linux and Mac), on Windows %USERPROFILE%\.aws\config file:
[default]
region=us-west-2
output=json
Using AWS credentials
If you don't want to or can't use AWS profiles, you can still supply Access Keys pair directly. In SDK, you can pass them to the constructor like this:
import { DynamoDB } from 'aws-sdk';
const config = {
apiVersion: "2010-12-01",
accessKeyId: process.env.AWS_ACCESS_KEY_ID, // hardcoding credentials is a bad practice
accessSecretKey: process.env.AWS_SECRET_ACCESS_KEY, // please use env vars instead
region: "us-east-1"
}
const ddb = new DynamoDB(config) // pass config to the constructor
AWS.config.update(config); // or call the update method directly
In CLI, you can use environment variables. If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not configured on your environment, you can prefix any CLI command with these, like this:
AWS_ACCESS_KEY_ID=PASTE_YOUR_KEY_HERE AWS_SECRET_ACCESS_KEY=PASTE_YOUR_SECRET_KEY_HERE aws s3 list-buckets
Alternatively, use export command to set required environment variables for all processes in current shell session:
export AWS_ACCESS_KEY_ID=PASTE_YOUR_KEY_HERE export AWS_SECRET_ACCESS_KEY=PASTE_YOUR_SECRET_KEY_HERE aws s3 list-buckets
Other Common DynamoDB Errors (with Solutions)
- dynamodb atomic counter not working
- dynamodb cannot read properties of undefined
- DynamoDB Update Not Working
- DynamoDB Duplicate Key Error
- DynamoDB - The Security Token Included In The Request Is Invalid
- DynamoDB Error All Attributes Must Be Indexed
- ValidationException: Invalid KeyConditionExpression: Attribute name is a reserved keyword;
- dynamodb the parameter cannot be converted to a numeric value
- dynamodb docker unable to open database file
- dynamodb unable to locate property for key attribute
- is not authorized to perform dynamodb:* on resource
- accessdeniedexception dynamodb
- dynamodb request is missing authentication token
- dynamodb number_value cannot be converted to string
- DynamoDB Internal Server Error
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
- New in Dynobase 3.0
- Semantic and Vector Search
- Schema Explorer
- Visual JSON Path Filtering
- Visual Item Diff
- MCP Server for AI Tools
- Use SQL with DynamoDB
- Import CSV To DynamoDB
- Import JSON To DynamoDB
- Export DynamoDB To JSON
- Export DynamoDB To S3
- Export DynamoDB To CSV
- DynamoDB Update Item
- DynamoDB Delete All Items
- DynamoDB Delete Item
- DynamoDB Create Table
- DynamoDB Delete Table
- DynamoDB Conditional Update