Skip to content

Instantly share code, notes, and snippets.

@apal21
Last active January 25, 2019 18:58
Show Gist options
  • Save apal21/46b54119bb9bc82775571f4028e6d2d2 to your computer and use it in GitHub Desktop.
Save apal21/46b54119bb9bc82775571f4028e6d2d2 to your computer and use it in GitHub Desktop.
Sample code to assume role and generate temporary credentials using a callback
const AWS = require('aws-sdk');
const sts = new AWS.STS();
sts.assumeRole({
DurationSeconds: 3600,
ExternalId: '1234-1234-1234-1234-1234',
RoleArn: "Your Role ARN",
RoleSessionName: 'abc'
}, (err, data) => {
if (err) throw err;
console.log(data); // successful response
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment