cloudsploit icon indicating copy to clipboard operation
cloudsploit copied to clipboard

Enable support for --profile option

Open matthewdfuller opened this issue 9 years ago • 6 comments
trafficstars

Allow multiple profiles to be used using AWS's CLI option for profiles.

matthewdfuller avatar Sep 28 '16 02:09 matthewdfuller

Awesome, thanks for opening this Matt

w1bble avatar Sep 28 '16 10:09 w1bble

Adding some notes here based on our testing so far.

  1. This will likely be a bit more difficult than expected if we use the traditional, AWS-supported route of passing the --profile flag.
  2. The reason is that we pass a custom AWS config object (containing credentials) to the individual plugins which then modify them to change the region. This functionality is core to our caching mechanism.
  3. When using the profile flag, the object that is returned does not contain the credentials required for the plugins to work, but rather a reference to the config file.
  4. There may be a middle-ground solution where we can define a list of available credentials in a separate file (or even use the existing ~/.aws/config.json file and load that at runtime.

We'll continue to investigate and update.

matthewdfuller avatar Oct 05 '16 01:10 matthewdfuller

Is this something expected to be supported? I have multiple accounts and would love to test against those with a solution like this.

hhh0505 avatar Jun 20 '18 18:06 hhh0505

Maybe you could use a simple wrapper script to get around the problem. This is assuming you have IAM role you can assume on account and then run Cloudsploit with that role. I've been using something like this for similar purposes. Change ROLE2ASSUME to match what your IAM role is called.

cloudsploit-wrapper.txt

kallu avatar Jul 17 '18 09:07 kallu

If --profile was specified, could you use STS:GetSessionToken to grab the three elements you populate into the AWSConfig object?

jchrisfarris avatar Sep 05 '18 01:09 jchrisfarris

I do similar to @kallu but in case anyone needs a one-liner:

export CREDS="$(aws sts get-session-token)" && export AWS_ACCESS_KEY_ID="$(echo $CREDS | jq -r .Credentials.AccessKeyId)"; export AWS_SECRET_ACCESS_KEY="$(echo $CREDS | jq -r .Credentials.SecretAccessKey)"; export AWS_SESSION_TOKEN="$(echo $CREDS | jq -r .Credentials.SessionToken)"

Thanks @jchrisfarris for the idea :-)

varunchandak avatar Aug 15 '21 03:08 varunchandak