I have a node service, which creates temporary AWS credentials using sts.assumeRole(params). If I set the accessKeyId,secretAccessKey,region in the environment. Credentials are generated successfully. If I store them in Mongo and read them. I get the following error.
Errors
Error Could not load credentials from any providers
Error region is missing
Code
const params = {
RoleArn: `arn:aws:iam::${db.awsAccountId}:role/${db.awsRole}`,
RoleSessionName: `Assumed-${db.awsRole}-Role-${timestamp}`,
accessKeyId: db.accessId,
secretAccessKey: db.accessToken,
region: db.awsRegion,
};
sts.assumeRole(params, (err, data) => {
if(err) console.log(err);
else console.log(data);
});
I don't understand, following the same procedure. Any ideas?