-
Notifications
You must be signed in to change notification settings - Fork 657
Support For AssumeRole #356
Comments
Put the keys in your credentials file in ~/.aws/credentials under a profile name and use the --profile switch when calling terraforming commands. |
First, please know how grateful I am that a tool like this exists out there. It has been very, very useful for me for many, many years. I think I first forked this project nearly two years ago. I've been a fan ever since. Main account ID w/ AssumeRole user: 000000000000 Confirmed working:
Steps to reproduce: Using the AWS CLI instead of Terraforming, I have a ~/.aws/config file where I stored "myuser" AWS keys (from IAM credentials provided in the Main account. It looks like this:
When I run the AWS CLI, it works:
I set up an identical profile in my ~/.aws/credentials file which looks like this:
When I run terraforming, here's what I get:
The really troubling part is:
I get the same issue with any other type of resource - ec2, rds, etc... It seems terraforming/AWS RubySDK is running listUsers on the 000000000000 account, instead of assuming the role in account 111111111111, and running IAM listUsers on that account...but I don't have that problem wit the AWS CLI version of the same command. Moreover, it seems like it's a known issue elsewhere with the way in which the AWS Client is first constructed in the RubySDK. I'm also parsing through your code and can't seem to find anything in the repo regarding Aws::STS::Client.new (creating STS client to acquire temporary AssumeRole credentials) or Aws::SharedCredentials.net (building shared credentials profile objects). For example, in your iam_user.rb, all I see is:
Please forgive the code below, I'm doing most of this off of a tablet, while in transit, so it's probably totally messed up -
Basically, I'm wondering if terraforming is capable of supporting a way to AssumeRole to other account resources, in order to list them? IF not, is it cool if I open a PR to try to work that out? |
@armenr we have multiple accounts and had same issue ... see if this works for you https://github.com/cmedley/terraforming/tree/support-assume-role (if it does, will open PR) |
@cmedley --> Thanks for that! This is clearly more elegant than any Ruby I was going to be able to hack together. I'm gonna take this for a test drive and see how it fares. Definitely glad someone around these parts forked and wrote it before I had the chance to mutilate the code. Thank you! |
@cmedley version is not working for me using |
I can confirm that I was able to get it working back in August/September when he shared it to me. I can try to test again and let you know...maybe help to repro the issue. |
I will test as well and update over weekend ... need to remove the
options[:client] from cli.rb and update the tests (but that wouldn't stop
it from working)
…On Fri, Oct 13, 2017 at 9:18 PM, Armen Rostamian ***@***.***> wrote:
I can confirm that I was able to get it working back in August/September
when he shared it to me.
I can try to test again and let you know...maybe help to repro the issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#356 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMSY38EUk4py5o68DPUD4xQChcfjcAQks5ssAvJgaJpZM4O74eh>
.
|
@varunchandak @armenr created a new pull request for assume role support ... #379 |
Amazing tool.Thank you so much for this ...is it possible to do terraforming for a specific resource? |
+1 |
I still cannot make this work. I can use aws with --profile flag working perfectly but with terraforming, I use --profile <as seen in .aws/credentials> and --assume <my ARN as seen in .aws/config> and I get nothing returned.... Example Credentials profile used:
Example Config file in use:
Example command and output...
Example aws usage and output
I can also describe instances and see proper results (too large to list here)... yet terraforming does not return anything for ec2 when using this config setup. |
@ddreggors think ec2 needs to go before the options $ terraforming ec2 --region ... |
You are correct, that fixed it right up thanks! |
@ddreggors @cmedley Using both
My ~/.aws/credentials looks like this:
|
@dimisjim what does the command look like that you are using? |
@cmedley Getting the same if I put |
@dimisjim getting same error as you ... to make this work it looks like we need to pass serial number and token code in the params to support MFA devices. I can get a PR going soon. Short term, you can use aws cli to create the credentials |
It's been 2 years, and you guys are still helping/supporting this feature and issue. So incredibly cool to see. //end gushy pointless post. |
@cmedley Awesome! How can I test this? |
@dimisjim can test this way
|
Ok, having some "require" difficulties with running the produced binary in terraforming/bin, I did the following: Assuming your instructions up to the
Then, having my ~/.aws/credentials file containing my default mfa profile that links to all the other accounts that it can assume a role there, I ran the command you proposed by omitting the --profile flag:
This worked beautifully! Can we proceed with merging the relevant PR #463 ? |
We run multiple accounts in AWS, one is a sandbox, others serve their own purposes. Is there some way to specify which account I want terraforming to use?
I have assume_role policies set up for the key/secret key I'm sourcing in my env, so the credentials work across any of the accounts.
I'm just trying to figure out what param to feed terraforming (if it supports it) so that it knows which account's resources to hit.
The text was updated successfully, but these errors were encountered: