-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AWS Profiles #21
Comments
Hi @pixie79, thanks for the question! Since terragrunt is written in Go and uses the AWS SDK for Go, the AWS authentication is handled completely by the AWS SDK. You can read about the specific authentication hierarchy used by the AWS SDK, which clarifies that terragrunt will first look for the If this answered your question, feel free to close this issue. Otherwise, I'll leave it open for a bit in case you have any follow-up questions. |
I notice you don't support the use of temporary credentials which require a 3rd environment variable, AWS_SESSION_TOKEN. We don't use IAM:users or issue long term access keys, instead we built a service that pulls temporary credentials via STS to provide access. It looks like the SDK supports STS but not sure the level of effort to include that with terragrunt. |
@mmorianos We are using the default credentials providers from the AWS Go SDK. Following that SDK code, it uses the CredChain function, which includes an EnvProvider, which, at least in theory, includes the AWS_SESSION_TOKEN environment variable. Did you try setting the three environment variables ( |
What's interesting is that it does seem to use the SESSION_TOKEN_ID to create the table for me, but then fails to write an entry in the statefile with it. I deleted the lock table and tried from scratch with those environment variables exported (
So, part of it works (creating the table) but part of it doesn't work (creating the lock item in the table) |
@ryangardner Hm, if some of the requests work, I think that means the auth is working. Perhaps "The security token included in the request is invalid" is just a poorly worded error message that actually means you lack the IAM permissions to write to that table? |
@ryangardner Ah, after a quick google search, I have an alternative theory: when creating a lock, the terragrunt code calls the IAM GetUser API. As I found from this comment in Terraform's issue tracker (which is relevant, since Terraform also uses the AWS Go SDK), if you are using the AWS APIs with dynamic credentials generated by Could you test this theory out? Use the AWS CLI to make some random API call (e.g. list the contents of an S3 bucket) and make sure it works with those env vars. Then, try this:
I'm guessing you'll get the same "security token included in the request is invalid" error. |
yep, that's the problem. aws iam get-user An error occurred (InvalidClientTokenId) when calling the GetUser operation: The security token included in the request is invalid |
Could you try enabling MFA and seeing if that fixes the issue? |
we experienced a similar problem with terraform and worked with them to modify the code and use the STS endpoint documented here... hashicorp/terraform#6536 |
@mmorianos Ah, nice find! I think Anyone interested in submitting a PR? |
I submitted a PR for this - as a side bonus of switching to |
A huge thanks to @ryangardner for submitting a fix. I've merged it in and just created a new release: https://github.com/gruntwork-io/terragrunt/releases/tag/v0.0.11 The CircleCI build is running now and in 5-10 minutes, the new binaries should be available at the URL above. Please give them a shot and let me know if things are working for you! |
so, The terragrunt will be retrieving aws credentials for remote state and dynamodb table. when |
@zerolaser Yes, that sounds right. Is that a problem? |
@brikis98 I do have multiple aws credentials set in ~/.aws/credentials. so when I pass |
@zerolaser Have you tried the |
Or maybe it's just |
@brikis98 setting AWS_PROFILE worked. thanks. |
OK, I'm going to mark this bug as closed. If anyone is still having issues, let us know, and we can re-open. |
Hi,
How does terragrunt interact with different AWS account credentials? Is there an option to set the profile in the config or will it respect the AWS_DEFAULT_PROFILE variable to get the correct API keys for use.
Thanks
Mark
The text was updated successfully, but these errors were encountered: