Looking at the code snippet below,
import { STS } from 'aws-sdk'
const sts = new STS({
region: 'us-east-1'
});
let accessKeyId: string
let secretAccessKey: string
sts.assumeRole(params, function(err, data) {
if (err) {
console.log(err, err.stack);
} else {
accessKeyId = data.Credentials?.AccessKeyId || '';
secretAccessKey = data.Credentials?.SecretAccessKey || '';
}
});
console.log(accessKeyId);
console.log(secretAccessKey);
When working in VS Code, I encountered an error stating "Variable 'accessKeyId' is used before being assigned." How can I ensure that these variables are set outside of the assumeRole() SDK call?