in src/lib/awsConnectionParameters.ts [263:302]
function createEndpointCredentials(
accessKey: string,
secretKey: string,
token: string | undefined,
assumeRoleARN: string | undefined,
externalId: string | undefined,
roleSessionName: string | undefined
): AWS.Credentials {
if (!assumeRoleARN) {
console.log('...endpoint defines standard access/secret key credentials')
return new AWS.Credentials({
accessKeyId: accessKey,
secretAccessKey: secretKey,
sessionToken: token
})
}
console.log(`...endpoint defines role-based credentials for role ${assumeRoleARN}.`)
if (!roleSessionName) {
roleSessionName = defaultRoleSessionName
}
const duration = getSessionDuration()
const masterCredentials = new AWS.Credentials({
accessKeyId: accessKey,
secretAccessKey: secretKey,
sessionToken: token
})
const options: STS.AssumeRoleRequest = {
RoleArn: assumeRoleARN,
DurationSeconds: duration,
RoleSessionName: roleSessionName
}
if (externalId) {
options.ExternalId = externalId
}
return new AWS.TemporaryCredentials(options, masterCredentials)
}