Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

Commit

Permalink
fix: use assumeRoleWithWebIdentity when using IRSA (external-secrets#416
Browse files Browse the repository at this point in the history
)

* add support for assumeRoleWithWebIdentity when used on AWS Fargate IRSA

* removed trailing spaces as detected by eslint
  • Loading branch information
lukaszbudnik committed Jun 24, 2020
1 parent 10e3991 commit 117b926
Showing 1 changed file with 12 additions and 0 deletions.
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 @@ -44,6 +45,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

0 comments on commit 117b926

Please sign in to comment.