-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
266 aws native config #801
Conversation
Big 👍 I'm not sure if this should be proposed in a separate PR, but it would affect this feature anyway. |
@BRMatt @radeksimko you might also be interested in #851. We switched to the "Standard AWS envvars". |
And this is related too I reckon: #390 |
@sethvargo thanks for the heads up. @radeksimko thanks for the link. That might be a bit out of scope for this PR, but I'll have a look to see if anything I add would cause problems for MFA. |
Basically it's just about one extra variable from config, so an example of 2FA-compatible config file would look like this:
|
fb8ee9c
to
1012094
Compare
@sethvargo Sorry for taking so long to get around to this, I've cleaned up my implementation and squashed it into one commit. It takes into account the new AWS variables (via goamz), but gives precedence to the older env vars until they're removed. I'd really appreciate any criticisms you have. @radeksimko I had a quick look at this, but unfortunately it's a bit more involved than just reading the extra config var (e.g. there's currently no variable in the schema to store the MFA token), so this PR intentionally focuses on just the access key id/secret key. |
1012094
to
3868d9c
Compare
@BRMatt It's nice to clean the code, but if it's not in a separate commit, it's hard to understand what the actual proposed change is as it's cluttering the whole diff. And btw. there are no coding standards defined for this project, at least I was not able to find any, so it's really hard to judge what kind of formatting is better. |
I'm just looking at this and thinking that modifying terraform that much may not be necessary as there's most of the Amazon-related logic in |
@radeksimko That's a good point, I should really have left the cleanup as a separate commit. The main changes this PR makes are in aws/provider.go, aws/provider_test.go, and the related website doc With regards to the formatting tweaks themselves, I just ran go-fmt on the aws package, as most projects seem to prefer it & it's part of the effective go guide. I'm presuming that's what this project uses as other commits reference it. |
That's true, and in fact this PR delegates most of the auth loading to
That said, I'd love to hear your thoughts, especially if you feel there's a better way of doing this! |
I generally think that if something is broken or behaving unexpectedly in Also, duplicating the auth logic in terraform does not seem useful to me (unless I'm missing something), so I'd even go down the path of removing it from terraform and relying completely on |
@radeksimko It's also worth noting that there's a larger effort (led by @catsby) to convert terraform entirely over to aws-go. So any |
@phinze ah, ok, that's good to know as I was just about to send a few PRs regarding 2FA support in config files and generally. Could you point us to the right library, please? |
Ah, right, I'm just being blind... #971 |
That's a reasonable assertion, however I think in this case the issue isn't that goamz is broken - it's perfectly reasonable for that library to prefer the |
This change also ensures that legacy env vars (AWS_ACCESS_KEY, AWS_SECRET_KEY) have precedence over the official aws-cli variation, and that both types of env var have precedence over settings in the credentials file. Note that this change technically supports different AWS credential profiles via the AWS_PROFILE env variable. The goamz library handles this. see - hashicorp#266 - hashicorp#866
0d20c02
to
67d8389
Compare
Going to close this in favor of #1049 since we removed goamz. I'm really sorry for not attending to this sooner, we should've told you that we weren't reading this yet since we were planning the switch away from goamz. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This is still a bit rough/verbose at the moment. Fairly new to Go so I'm sure there things I've done which aren't idiomatic. Please let me know if I've done something wrong/there is a better way to do this with terraform.
Tests pass locally, but I haven't run a full integration test against AWS to verify. Also, the credentials file is being loaded every time
DefaultFunc
is called, which probably isn't very efficient. Not sure how much of an issue this will be in practice though?refs #266
TODO:
~/.aws/credentials
AWS_PROFILE
(this is handled by goamz)Load config from(amazon say this file is meant solely for their CLI tool)~/.aws/config