-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Set AWS credentials in the environment so go-getter can use them #775
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
base: main
Are you sure you want to change the base?
Set AWS credentials in the environment so go-getter can use them #775
Conversation
I was going through the terragrunt code yesterday and found very good comments in it, explaining why something was done. So for this, I would add a note as well, something like "it's for go-getter not doing the auth right". Just my 2 cents. |
// Set these directly as environment variables so that go-getter can download artifacts from S3 | ||
os.Setenv("AWS_ACCESS_KEY_ID", aws.StringValue(creds.AccessKeyId)) | ||
os.Setenv("AWS_SECRET_ACCESS_KEY", aws.StringValue(creds.SecretAccessKey)) | ||
os.Setenv("AWS_SESSION_TOKEN", aws.StringValue(creds.SessionToken)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I'm grateful for the attempt at a simple fix, but I'm 95% sure this approach is going to cause other problems:
- We run Terragrunt's tests in parallel, some of which use different auth strategies. If we set global env vars here, that will affect all tests, and cause strange, intermittent behavior depending on which tests happen to run in parallel.
- Terragrunt itself runs things in parallel when you run
xxx-all
commands (e.g.,apply-all
). If you have different modules that use different auth settings, this again will cause strange race conditions based on timing.
So, I suspect that either we need a way to explicitly set auth values when executing an instance of go-getter
, if it's API exposes that ability... And if not, fix the bug in go-getter
itself.
In going from 0.18.7 to 0.19.0, the method for downloading Terraform sources changed from
terraform init
to the hashicorp/go-getter library. This introduces a regression where an artifact in S3 can no longer be fetched using an assumed role..ssh/config
Failing output with Terragrunt 0.19.8 and Terraform 0.12.3:
Output with Terragrunt built off of this PR:
This is likely actually an issue with the go-getter library not properly handling AWS credentials, but the change in this PR is a lower effort fix. I've tested that this fixes the issue in my setup. I've also tested separately that having Terragrunt pull in hashicorp/go-getter#185 (which looks related) does not fix my issue.