victorskl / yawsso

Yet Another AWS SSO - sync up AWS CLI v2 SSO login session to legacy CLI v1 credentials
MIT License
304 stars 27 forks source link

How does it find aws-cli version? #45

Closed zhaoyi0113 closed 3 years ago

zhaoyi0113 commented 3 years ago

I am running the command but got this message:

$ yawsso -p 00 -e
Required AWS CLI v2. Found aws-cli/1.18.0 Python/3.7.4 Darwin/20.2.0 botocore/1.12.253

it says AWS Cli version is 1.18.0. However, I have installed v2.

$ aws --version
aws-cli/2.1.22 Python/3.7.4 Darwin/20.2.0 exe/x86_64 prompt/off

how does yawsso find the aws cli version?

victorskl commented 3 years ago

That's a bit odd, yes. Umm, would you mind use --trace to see any meaningful pointer to where the issue might be.

It is using Python built-in shutil.which module to find aws binary in your current shell env PATH. As last resort, you can use -b (or --bin) flag to point the absolute path of the AWS v2 binary location. I made it that for those folks using both v1 alias to aws and; v2 such that aws2.

Happy to provide more if I can see some trace output. Please mask any private info, if any.

zhaoyi0113 commented 3 years ago

The output from --trace is:

2021-01-30 19:59:37,433 yawsso.cli   TRACE    Logging level: TRACE
2021-01-30 19:59:37,434 yawsso.cli   TRACE    args: Namespace(bin=None, command=None, debug=False, default=False, default_only=False, export_vars1=True, profiles=['00'], trace=True, version=False)
2021-01-30 19:59:37,434 yawsso.cli   TRACE    AWS_CONFIG_FILE: /Users/joey/.aws/config
2021-01-30 19:59:37,434 yawsso.cli   TRACE    AWS_SHARED_CREDENTIALS_FILE: /Users/joey/.aws/credentials
2021-01-30 19:59:37,434 yawsso.cli   TRACE    AWS_SSO_CACHE_PATH: /Users/joey/.aws/sso/cache
2021-01-30 19:59:37,434 yawsso.cli   TRACE    Cache SSO JSON files: ['/Users/joey/.aws/sso/cache/c9f2ab5ada1a3d25651c848225b644f863a38826.json', '/Users/joey/.aws/sso/cache/botocore-client-id-ap-southeast-2.json']
2021-01-30 19:59:37,872 yawsso.cli   ERROR    Required AWS CLI v2. Found aws-cli/1.18.0 Python/3.7.4 Darwin/20.2.0 botocore/1.12.253

Do you see anything wrong in the output?

victorskl commented 3 years ago

Do you see anything wrong in the output?

Nop.

Probably related with how you setup your shell environment PATH and Python, I reckon. Show output of these commands:

yawsso --version
aws --version
python -V
python3 -V
pip -V
pip3 -V

which yawsso
which aws
which python
which python3
which pip
which pip3
zhaoyi0113 commented 3 years ago

Below is the output.

Joey-Zeller:k8s joey$ yawsso --version
yawsso 0.6.1
Joey-Zeller:k8s joey$ aws --version
aws-cli/2.1.22 Python/3.7.4 Darwin/20.2.0 exe/x86_64 prompt/off
Joey-Zeller:k8s joey$ python -V
Python 3.7.4
Joey-Zeller:k8s joey$ python3 -V
Python 3.7.4
Joey-Zeller:k8s joey$ pip -V
pip 21.0 from /Users/joey/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pip (python 3.7)
Joey-Zeller:k8s joey$ pip3 -V
pip 20.0.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

Joey-Zeller:k8s joey$ which python
/Users/joey/.pyenv/shims/python
Joey-Zeller:k8s joey$ which python3
/Users/joey/.pyenv/shims/python3
Joey-Zeller:k8s joey$ which pip
/Users/joey/.pyenv/shims/pip
Joey-Zeller:k8s joey$ which pip3
/usr/local/bin//pip3
victorskl commented 3 years ago

Please also include output of

which yawsso
which aws
ls -l $(which aws)
eval $(which aws) --version

Also try which aws output path directly with -b flag. Example:

yawsso -b $(which aws) -p 00 -e
zhaoyi0113 commented 3 years ago
Joey-Zeller:entity joey$ which yawsso
/Users/joey/.pyenv/shims/yawsso

$ which aws
/usr/local/bin//aws

Joey-Zeller:entity joey$ ls -l $(which aws)
lrwxr-xr-x  1 root  staff  22 30 Jan 14:47 /usr/local/bin//aws -> /usr/local/aws-cli/aws

Joey-Zeller:entity joey$ eval $(which aws) --version
aws-cli/2.1.22 Python/3.7.4 Darwin/20.2.0 exe/x86_64 prompt/off

Joey-Zeller:entity joey$ yawsso -b $(which aws) -p 00 -e
No section: 'profile 00'

I see that the command yawsso -b $(which aws) -p 00 -e works but when I run it without -b, it complains about the aws version.

zhaoyi0113 commented 3 years ago

issue is resolved after reinstall awscli. Thanks