From 27186a2be8b997fc4846d9716a46a53a98f29fc4 Mon Sep 17 00:00:00 2001 From: Brian Antonelli Date: Thu, 6 Feb 2020 10:19:25 -0500 Subject: [PATCH 1/5] Adds output format support for AWS --- README.md | 1 + lib/keys.js | 12 ++++++++++-- lib/utils.js | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 17c9c014..f456c284 100644 --- a/README.md +++ b/README.md @@ -288,3 +288,4 @@ ALKS CLI will output in a variety of formats, it uses the developer default (set * `fishshell`: Outputs environment variables for Fishshell * `terraformenv`: Outputs environment variables prefixed with `ALKS` * `terraformarg`: Outputs environment arguments to pass to a Docker run call prefixed with `ALKS` +* `aws`: Outputs environment arguments to pass to AWS diff --git a/lib/keys.js b/lib/keys.js index e485e64f..490d7840 100644 --- a/lib/keys.js +++ b/lib/keys.js @@ -121,7 +121,7 @@ function updateCreds(key, profile, force){ exports.addKey = function(accessKey, secretKey, sessionToken, alksAccount, alksRole, expires, auth, isIAM, callback){ var enc = auth.token || auth.password; - + getKeysCollection(function(err, keys){ keys.insert({ accessKey: encrypt(accessKey, enc), @@ -260,7 +260,15 @@ exports.getKeyOutput = function(format, key, profile, force){ cmd, ' AWS_SECRET_ACCESS_KEY=', key.secretKey, ' && ', cmd, ' AWS_SESSION_TOKEN=', key.sessionToken, ' && ', cmd, ' AWS_SESSION_EXPIRES=', keyExpires - ].join(''); + ].join(''); + } + else if(format === 'aws'){ + return JSON.stringify({ + 'AccessKeyId': key.accessKey, + 'SecretAccessKey': key.secretKey, + 'SessionToken': key.sessionToken, + 'Expiration': keyExpires + }); } else{ var cmd = utils.isWindows() ? 'SET' : 'export'; diff --git a/lib/utils.js b/lib/utils.js index 10910fce..43545fe0 100755 --- a/lib/utils.js +++ b/lib/utils.js @@ -67,7 +67,7 @@ exports.getFilePathInHome = function(filename){ exports.getOutputValues = function(){ // if adding new output types be sure to update keys.js:getKeyOutput - return [ 'env', 'json', 'docker', 'creds', 'idea', 'export', 'set', 'powershell', 'fishshell', 'terraformenv', 'terraformarg' ]; + return [ 'env', 'json', 'docker', 'creds', 'idea', 'export', 'set', 'powershell', 'fishshell', 'terraformenv', 'terraformarg', 'aws' ]; }; exports.trim = function(str){ From 4adcaa51df8eecaeac645018bd7ee72acc464e1b Mon Sep 17 00:00:00 2001 From: Webb Barker Date: Tue, 11 Feb 2020 09:47:10 -0500 Subject: [PATCH 2/5] Adds version key to 'aws' output type --- lib/keys.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/keys.js b/lib/keys.js index 490d7840..97a30813 100644 --- a/lib/keys.js +++ b/lib/keys.js @@ -264,6 +264,7 @@ exports.getKeyOutput = function(format, key, profile, force){ } else if(format === 'aws'){ return JSON.stringify({ + 'Version': 1, 'AccessKeyId': key.accessKey, 'SecretAccessKey': key.secretKey, 'SessionToken': key.sessionToken, From b51cfd3e3619efe7f86d31b6250950721bde99bb Mon Sep 17 00:00:00 2001 From: Webb Barker Date: Tue, 11 Feb 2020 09:51:15 -0500 Subject: [PATCH 3/5] Corrects unix permission issue with alks-iam-createtrustrole --- bin/alks-iam-createtrustrole | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/alks-iam-createtrustrole diff --git a/bin/alks-iam-createtrustrole b/bin/alks-iam-createtrustrole old mode 100644 new mode 100755 From bc15d7278b0c6990af52c91aeca3503b79d72f2e Mon Sep 17 00:00:00 2001 From: Webb Barker Date: Tue, 11 Feb 2020 10:23:04 -0500 Subject: [PATCH 4/5] Adds link to AWS docs in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f456c284..a33aa0ce 100644 --- a/README.md +++ b/README.md @@ -288,4 +288,4 @@ ALKS CLI will output in a variety of formats, it uses the developer default (set * `fishshell`: Outputs environment variables for Fishshell * `terraformenv`: Outputs environment variables prefixed with `ALKS` * `terraformarg`: Outputs environment arguments to pass to a Docker run call prefixed with `ALKS` -* `aws`: Outputs environment arguments to pass to AWS +* `aws`: Outputs environment arguments to pass to AWS (docs)[https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html] From 78e3ad2ffe880297a32f21d846df3b01568a02d7 Mon Sep 17 00:00:00 2001 From: Webb Barker Date: Tue, 11 Feb 2020 10:31:08 -0500 Subject: [PATCH 5/5] Fix hyperlink formatting in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a33aa0ce..c2965abd 100644 --- a/README.md +++ b/README.md @@ -288,4 +288,4 @@ ALKS CLI will output in a variety of formats, it uses the developer default (set * `fishshell`: Outputs environment variables for Fishshell * `terraformenv`: Outputs environment variables prefixed with `ALKS` * `terraformarg`: Outputs environment arguments to pass to a Docker run call prefixed with `ALKS` -* `aws`: Outputs environment arguments to pass to AWS (docs)[https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html] +* `aws`: Outputs environment arguments to pass to AWS [docs](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html)