Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

add support for assumeRoleWithWebIdentity when used on AWS Fargate IRSA #416

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions config/aws-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const clonedeep = require('lodash.clonedeep')
const merge = require('lodash.merge')

const localstack = process.env.LOCALSTACK || 0
const webIdentity = process.env.AWS_WEB_IDENTITY_TOKEN_FILE || 0

let secretsManagerConfig = {}
let systemManagerConfig = {}
Expand Down Expand Up @@ -41,6 +42,17 @@ module.exports = {
},
assumeRole: (assumeRoleOpts) => {
const sts = new AWS.STS(stsConfig)
if (webIdentity) {
return new Promise((resolve, reject) => {
sts.assumeRoleWithWebIdentity(assumeRoleOpts, (err, res) => {
if (err) {
return reject(err)
}
resolve(res)
})
})
}

return new Promise((resolve, reject) => {
sts.assumeRole(assumeRoleOpts, (err, res) => {
if (err) {
Expand Down