I am getting below error when trying to connect to dynamoDB after getting credentials from aws secret manager.
Uncaught (in promise) CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
But when I try with hardcoded keys, it’s working fine. Can anyone conform what I am doing wrong here. Below is my code:
import * as AWS from 'aws-sdk';
const region = 'my-region';
const SecretId = "secret-name";
const client = new AWS.SecretsManager({
region: region
});
client.getSecretValue({ SecretId: SecretId }).promise()
.then((secretValue: any)=>{
const secretString = JSON.parse(secretValue.SecretString)
console.log(secretString)
AWS.config.update({
region: region,
accessKeyId: secretString.AWS_ACCESS_KEY_ID,
secretAccessKey: secretString.AWS_SECRET_ACCESS_KEY
});
});