From 548df3455d7bfd4e3df5012e3a81d14d573e1d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Budnik?= Date: Mon, 18 May 2020 21:33:40 +0200 Subject: [PATCH 1/2] add support for assumeRoleWithWebIdentity when used on AWS Fargate IRSA --- config/aws-config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config/aws-config.js b/config/aws-config.js index 73a30dc6..647f9777 100644 --- a/config/aws-config.js +++ b/config/aws-config.js @@ -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 = {} @@ -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) { From 66d88d04c4575163147d0269571dbafd2f5ea521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Budnik?= Date: Wed, 24 Jun 2020 16:06:29 +0200 Subject: [PATCH 2/2] removed trailing spaces as detected by eslint --- config/aws-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/aws-config.js b/config/aws-config.js index 647f9777..d0f52fd7 100644 --- a/config/aws-config.js +++ b/config/aws-config.js @@ -52,7 +52,7 @@ module.exports = { }) }) } - + return new Promise((resolve, reject) => { sts.assumeRole(assumeRoleOpts, (err, res) => { if (err) {