diff --git a/README.md b/README.md index 17c9c014..c2965abd 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 [docs](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html) diff --git a/bin/alks-iam-createtrustrole b/bin/alks-iam-createtrustrole old mode 100644 new mode 100755 diff --git a/lib/keys.js b/lib/keys.js index e485e64f..97a30813 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,16 @@ 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({ + 'Version': 1, + '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){