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

aws: really unset AWS*PROFILE variables in asp function #7838

Merged
merged 2 commits into from May 10, 2019

Conversation

@haidaraM
Copy link
Contributor

haidaraM commented May 10, 2019

When running asp without arguments to clear an exported profile, the variables AWS_DEFAULT_PROFILE, AWS_PROFILE and AWS_EB_PROFILE are left "blank". There are not removed from the envrionment variables.

This causes the AWS CLI (and I guess some SDKs also) to try to find a profile with an empty name.

Example when no profile is exported (no AWS*PROFILE variable is exported):

$ aws s3 ls
Unable to locate credentials. You can configure credentials by running "aws configure".

Example when asp is run without arguments to clear an exported profile:

$ aws s3 ls
Traceback (most recent call last):
  File "/usr/local/bin/aws", line 27, in <module>
    sys.exit(main())
  File "/usr/local/bin/aws", line 23, in main
    return awscli.clidriver.main()
  File "/usr/local/lib/python3.6/site-packages/awscli/clidriver.py", line 59, in main
    rc = driver.main()
  File "/usr/local/lib/python3.6/site-packages/awscli/clidriver.py", line 193, in main
    command_table = self._get_command_table()
  File "/usr/local/lib/python3.6/site-packages/awscli/clidriver.py", line 102, in _get_command_table
    self._command_table = self._build_command_table()
  File "/usr/local/lib/python3.6/site-packages/awscli/clidriver.py", line 122, in _build_command_table
    command_object=self)
  File "/usr/local/lib/python3.6/site-packages/botocore/session.py", line 671, in emit
    return self._events.emit(event_name, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/usr/local/lib/python3.6/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/awscli/customizations/preview.py", line 69, in mark_as_preview
    service_name=original_command.service_model.service_name,
  File "/usr/local/lib/python3.6/site-packages/awscli/clidriver.py", line 318, in service_model
    return self._get_service_model()
  File "/usr/local/lib/python3.6/site-packages/awscli/clidriver.py", line 335, in _get_service_model
    api_version = self.session.get_config_variable('api_versions').get(
  File "/usr/local/lib/python3.6/site-packages/botocore/session.py", line 233, in get_config_variable
    logical_name)
  File "/usr/local/lib/python3.6/site-packages/botocore/configprovider.py", line 226, in get_config_variable
    return provider.provide()
  File "/usr/local/lib/python3.6/site-packages/botocore/configprovider.py", line 323, in provide
    value = provider.provide()
  File "/usr/local/lib/python3.6/site-packages/botocore/configprovider.py", line 382, in provide
    config = self._session.get_scoped_config()
  File "/usr/local/lib/python3.6/site-packages/botocore/session.py", line 334, in get_scoped_config
    raise ProfileNotFound(profile=profile_name)
botocore.exceptions.ProfileNotFound: The config profile () could not be found

This PR explicitly unset these environment variables :-)

  • zsh 5.3 (x86_64-apple-darwin18.0)
  • aws-cli/1.16.139 Python/3.6.7 Darwin/18.5.0 botocore/1.12.129
@haidaraM

This comment has been minimized.

Copy link
Contributor Author

haidaraM commented May 10, 2019

@mcornella

This comment has been minimized.

Copy link
Member

mcornella commented May 10, 2019

Thanks! I didn't have an aws environment so I hadn't tested it.

@mcornella mcornella changed the title aws plugin fix: unset AWS*PROFILE variables when function asp has no argument aws: really unset AWS*PROFILE variables in asp function May 10, 2019
@mcornella mcornella merged commit 4585c66 into ohmyzsh:master May 10, 2019
beimingxinghai pushed a commit to beimingxinghai/oh-my-zsh that referenced this pull request Jun 4, 2019
atsuya added a commit to atsuya/oh-my-zsh that referenced this pull request Jun 9, 2019
dukegod added a commit to dukegod/oh-my-zsh that referenced this pull request Jul 16, 2019
chihchun added a commit to chihchun/oh-my-zsh that referenced this pull request Aug 6, 2019
ahamilton55 added a commit to ahamilton55/oh-my-zsh that referenced this pull request Sep 2, 2019
saep added a commit to saep/oh-my-zsh that referenced this pull request Sep 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.