This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to assume role (#144)
* feat: add option to assume role when retrieving secrets Signed-off-by: Moritz Johner <[email protected]> * feat: restrict iam roles per namespace add option to restrict the range of assumed roles by specifying an regular expression on a namespace annotation Signed-off-by: Moritz Johner <[email protected]> * chore: add test to verify assume-role access control * docs: add policy for secrets manager * docs: add assume-role limits per ns Signed-off-by: Moritz Johner <[email protected]> * docs: fix spelling Signed-off-by: Moritz Johner <[email protected]> * chore: remove stupid code
- Loading branch information
Showing
14 changed files
with
381 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,36 @@ | ||
'use strict' | ||
|
||
/* eslint-disable no-process-env */ | ||
const AWS = require('aws-sdk') | ||
|
||
const localstack = process.env.LOCALSTACK || 0 | ||
|
||
const secretsManagerConfig = localstack ? { endpoint: 'http://localhost:4584', region: 'us-west-2' } : {} | ||
const systemManagerConfig = localstack ? { endpoint: 'http://localhost:4583', region: 'us-west-2' } : {} | ||
const stsConfig = localstack ? { endpoint: 'http://localhost:4592', region: 'us-west-2' } : {} | ||
|
||
module.exports = { | ||
secretsManagerConfig, | ||
systemManagerConfig | ||
secretsManagerFactory: (opts) => { | ||
if (localstack) { | ||
opts = secretsManagerConfig | ||
} | ||
return new AWS.SecretsManager(opts) | ||
}, | ||
systemManagerFactory: (opts) => { | ||
if (localstack) { | ||
opts = systemManagerConfig | ||
} | ||
return new AWS.SSM(opts) | ||
}, | ||
assumeRole: (assumeRoleOpts) => { | ||
const sts = new AWS.STS(stsConfig) | ||
return new Promise((resolve, reject) => { | ||
sts.assumeRole(assumeRoleOpts, (err, res) => { | ||
if (err) { | ||
return reject(err) | ||
} | ||
resolve(res) | ||
}) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.