Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save apal21/70ba21996d6d401435813ff0e06a3e58 to your computer and use it in GitHub Desktop.
Save apal21/70ba21996d6d401435813ff0e06a3e58 to your computer and use it in GitHub Desktop.
Sample code to assume role and generate temporary credentials using async/await
const AWS = require('aws-sdk');
const sts = new AWS.STS();
(async () => {
try {
const data = await sts.assumeRole({
DurationSeconds: 3600,
ExternalId: '1234-1234-1234-1234-1234',
RoleArn: "Your Role ARN",
RoleSessionName: 'abc',
}).promise();
console.log(data);
} catch (e) {
console.log(e);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment