Skip to content
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

Honor $AWS_CONFIG_FILE env variable #540

Closed
argoyle opened this issue Aug 17, 2023 · 9 comments · Fixed by #541
Closed

Honor $AWS_CONFIG_FILE env variable #540

argoyle opened this issue Aug 17, 2023 · 9 comments · Fixed by #541
Labels
enhancement New feature or request
Milestone

Comments

@argoyle
Copy link

argoyle commented Aug 17, 2023

Is your feature request related to a problem? Please describe.
I'm working for multiple clients and have split my AWS configuration in different directories by help of direnv and setting the env-vars AWS_CONFIG_FILE/AWS_SHARED_CREDENTIALS_FILE to point at a directory specific for each client. aws-sso seems to ignore those and always updates ~/.aws/config.

Describe the solution you'd like
A possibility to handle config per client somehow

@argoyle argoyle added the enhancement New feature or request label Aug 17, 2023
@synfinatic
Copy link
Owner

This sounds like a good idea! AWS_CONFIG_FILE makes a lot of sense, but I'm not really sure what aws-sso should do with AWS_SHARED_CREDENTIALS_FILE?

@synfinatic
Copy link
Owner

Another question: is this mapping of roles to config files static or dynamic? Ie: is this something you want to manage outside of aws-sso (managing this environment variable to change where the same roles get written to) or something you really want to set & forget (adding this to the aws-sso config file).

@argoyle
Copy link
Author

argoyle commented Aug 17, 2023

You're probably correct regarding the credentials-file, I just mentioned it since I set that along with the config-var.

I handle this using direnv today so in each of my client-directories I have a .envrc-file which defines where the AWS-tooling should look for config and credentials. I actually already added the AWS_SSO_CONFIG to my files in the hope that the rest should "just work ™️" 😊

@synfinatic synfinatic changed the title Support for env-vars AWS_CONFIG_FILE/AWS_SHARED_CREDENTIALS_FILE Honor $AWS_CONFIG_FILE env variable Aug 17, 2023
@synfinatic synfinatic added this to the v1.13.0 milestone Aug 17, 2023
@synfinatic
Copy link
Owner

synfinatic commented Aug 17, 2023

So looking at the code... it should work today?

I just tested with AWS_CONFIG_FILE=~/config aws-sso config-profiles and wrote out everything to the specified alternate file instead of ~/.aws/config

What version of aws-sso are you using?

@argoyle
Copy link
Author

argoyle commented Aug 18, 2023

Hmmm, config-profiles seems to do the correct thing. When I just ran aws-sso config it asked if it should update ~/.aws/config though.

@argoyle
Copy link
Author

argoyle commented Aug 18, 2023

Even more strange. In one of my client directories config-profiles did this:

The following changes are proposed to /Users/argoyle/.aws/config:
--- /Users/argoyle/.aws/config
+++ /Users/argoyle/.aws/config.new
@@ -1 +1,23 @@
+# BEGIN_AWS_SSO_CLI
+
...profiles
+
+# END_AWS_SSO_CLI


Modify /Users/argoyle/.aws/config with proposed changes?: No
The following changes are proposed to /Users/argoyle/Source/CustomerProjects/<client>/.aws/config:
--- /Users/argoyle/Source/CustomerProjects/<client>/.aws/config
+++ /Users/argoyle/Source/CustomerProjects/<client>/.aws/config.new
@@ -13,3 +13,22 @@
 output = json
+# BEGIN_AWS_SSO_CLI
+
...profiles
+
+# END_AWS_SSO_CLI


Modify /Users/argoyle/Source/CustomerProjects/<client>/.aws/config with proposed changes?: Yes

Maybe my aws-sso config was strange there. I think I've already set that up earlier. Will try in another directory.

@argoyle
Copy link
Author

argoyle commented Aug 18, 2023

Another client was fine so probably something strange in my config

@argoyle
Copy link
Author

argoyle commented Aug 18, 2023

Aaah, I had enabled AutoConfigCheck in that config. That seems to want to update the default path always.

@synfinatic
Copy link
Owner

Awesome. that helps a lot.

synfinatic added a commit that referenced this issue Aug 19, 2023
- AutoConfigCheck workflow now looks at the AWS_CONFIG_FILE env var
- `config-profiles` now offers an explict flag
- Refactor code

Fixes: #540
synfinatic added a commit that referenced this issue Aug 19, 2023
- AutoConfigCheck workflow now looks at the AWS_CONFIG_FILE env var
- `config-profiles` now offers an explict flag
- Refactor code

Fixes: #540
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants