aws / aws/aws-elastic-beanstalk-cli-setup
EB CLI does not respect credentials in environment
- Dominant language
- Python
- Stars
- 537
- Forks
- 226
- PR merge metrics
- No merged PRs in 30d
Description
(This is a bug report about the actual EB CLI itself; if there's another place to report it, please let me know.)
I am setting up the EB CLI in a CI environment and will be providing credentials as environment variables. For testing, I have exported these environment variables in bash:
```
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=UML...
```
I expect that when I run `eb list` I will see the environments available to that key's user. However, I get this debug output:
```
...
2020-10-13 18:29:29,001 (DEBUG) ebcli.lib.elasticbeanstalk : Inside get_app_environments api wrapper
2020-10-13 18:29:29,001 (DEBUG) ebcli.lib.aws : Creating new Botocore Session
2020-10-13 18:29:29,001 (DEBUG) ebcli.lib.aws : Botocore version: 1.17.63
2020-10-13 18:29:29,012 (DEBUG) ebcli.lib.aws : Creating new Botocore Client for elasticbeanstalk
2020-10-13 18:29:29,014 (INFO) eb : Traceback (most recent call last):
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/lib/aws.py", line 152, in _get_client
config=Config(signature_version='s3v4'))
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/botocore/session.py", line 805, in create_client
api_version = self.get_config_variable('api_versions').get(
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/botocore/session.py", line 241, in get_config_variable
logical_name)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/botocore/configprovider.py", line 293, in get_config_variable
return provider.provide()
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/botocore/configprovider.py", line 390, in provide
value = provider.provide()
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/botocore/configprovider.py", line 451, in provide
scoped_config = self._session.get_scoped_config()
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/botocore/session.py", line 340, in get_scoped_config
raise ProfileNotFound(profile=profile_name)
botocore.exceptions.ProfileNotFound: The config profile (eb-cli) could not be found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/core/ebrun.py", line 62, in run_app
app.run()
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/cement/core/foundation.py", line 797, in run
return_val = self.controller._dispatch()
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/cement/core/controller.py", line 472, in _dispatch
return func()
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/cement/core/controller.py", line 478, in _dispatch
return func()
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/core/abstractcontroller.py", line 92, in default
self.do_command()
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/controllers/list.py", line 37, in do_command
listops.list_env_names(app_name, verbose, all_apps)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/operations/listops.py", line 29, in list_env_names
list_env_names_for_app(app_name, verbose)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/operations/listops.py", line 34, in list_env_names_for_app
env_names = elasticbeanstalk.get_environment_names(app_name)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/lib/elasticbeanstalk.py", line 624, in get_environment_names
environments = get_app_environments(app_name)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/lib/elasticbeanstalk.py", line 572, in get_app_environments
**kwargs)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/lib/elasticbeanstalk.py", line 39, in _make_api_call
**operation_options)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/lib/aws.py", line 194, in make_api_call
operation = _set_operation(service_name, operation_name)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/lib/aws.py", line 315, in _set_operation
client = _get_client(service_name)
File "/home/jenkins/.ebcli-virtual-env/lib/python3.7/site-packages/ebcli/lib/aws.py", line 155, in _get_client
raise InvalidProfileError(e)
ebcli.objects.exceptions.InvalidProfileError: The config profile (eb-cli) could not be found
```
There is logic in `ebcli.operations.commonops` that _appears_ to be trying to detect the presence of the environment variables and use a profile `None`, but it straight-up doesn't work.
To reproduce, check out a project with an existing deployment configuration. With no AWS configuration files present, set the environment variables and run `eb list`.
Contributor guide
Research direction
Reproduce the failure with no AWS configuration files, the two environment variables set, and `eb list`. Start in `ebcli.operations.commonops` to inspect credential and profile selection, then follow client creation in `ebcli/lib/aws.py`. Done means environment credentials are honored and `eb list` completes without the `eb-cli` ProfileNotFound error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100