Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Unset environment variables more consistently. #242

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

smarnach
Copy link

We noticed that maws currently does not unset the AWS_SECURITY_TOKEN evnironment variable, which can lead to confusing behaviour if it is still set. This PR makes sure this env variable is always unset, and makes unsetting env vars overall a bit more consistent.

It's not tested at all, and probably needs unit tests, so this is still a draft.

"AWS_SHARED_CREDENTIALS_FILE": None,
"MAWS_PROMPT": self.display_name})
{var: self.credentials.get(key)
for key, var in ENV_VARIABLE_NAME_MAP.item()})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encountered error : Unable to contact AWS : Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/mozilla_aws_cli-1.2.4-py3.9.egg/mozilla_aws_cli/login.py", line 363, in exchange_token_for_credentials
self.print_output()
File "/usr/local/lib/python3.9/dist-packages/mozilla_aws_cli-1.2.4-py3.9.egg/mozilla_aws_cli/login.py", line 428, in print_output
for key, var in ENV_VARIABLE_NAME_MAP.item()})
AttributeError: 'dict' object has no attribute 'item'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that! Should be .items(). Fixed now (togerther with a few other clean-ups). This time I at least did a basic test that it's still working.

@gene1wood
Copy link
Contributor

I think this is a good idea (unsetting those variables). This PR may be the way to do it, or maybe some other approach. Either way, ya we should introduce this change in some form.

@bkochendorfer
Copy link
Member

Hey @smarnach have you been running this locally for a while? It seems fine to me with your update.

@smarnach
Copy link
Author

smarnach commented Apr 5, 2022

Yes, I ran this locally since I filed the PR, and didn't run into any issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants