Created
January 25, 2019 09:27
-
-
Save apal21/70ba21996d6d401435813ff0e06a3e58 to your computer and use it in GitHub Desktop.
Sample code to assume role and generate temporary credentials using async/await
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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