awscli-plugin-endpoint icon indicating copy to clipboard operation
awscli-plugin-endpoint copied to clipboard

How to use with AWS CLI v2

Open ches opened this issue 4 years ago • 6 comments

I'll send a PR for the README if I have a few more minutes, but thought I'd share how to get the plugin working in the v2 CLI for others that may see it here—it took finding separate answers for a couple of issues:

  • Use the CLI's bundled Python with pip install --no-deps awscli-plugin-endpoint. (This will mean something like /usr/local/opt/awscli/libexec/bin/pip depending on installation).

  • Add the new cli_legacy_plugin_path setting in ~/.aws/config—see aws/aws-cli#4854:

    [plugins]
    cli_legacy_plugin_path = /usr/local/opt/awscli/libexec/lib/python3.8/site-packages
    endpoint = awscli_plugin_endpoint
    

They don't want to release v2 on PyPI. So without --no-deps I was getting:

$ /usr/local/opt/awscli/libexec/bin/pip install awscli-plugin-endpoint
[snip]
Requirement already satisfied: awscli>=1.11.0 in /usr/local/Cellar/awscli/2.0.0_1/libexec/lib/python3.8/site-packages (from awscli-plugin-endpoint) (2.0.0)
ERROR: No matching distribution found for botocore==2.0.0dev4 (from awscli>=1.11.0->awscli-plugin-endpoint)

It looks like the plugin's awscli>=1.11.0 dependency triggers pip to try to resolve deps including the CLI's, and fails because botocore v2 releases aren't published to PyPI either.

After these two steps, the plugin is working for me. Thanks for making it!

$ aws --version
aws-cli/2.0.0 Python/3.8.2 Darwin/18.7.0 botocore/2.0.0dev7

ches avatar Mar 13 '20 19:03 ches

Thanks a lot for the info. Will update to the README.

wbingli avatar Jul 22 '20 06:07 wbingli

Hi @wbingli - the readme still says pip install awscli-plugin-endpoint regardless of cli version. This only worked for the cli v2 when I did pip install --no-deps awscli-plugin-endpoint. Could you please call that out in the readme?

Thanks for the awesome plugin!

rbrianhazzard avatar Oct 28 '20 13:10 rbrianhazzard

This still isn't working for me. How did you get alwscli to load the modules? I always get e.g. ModuleNotFoundError: No module named '/usr/local/opt/awscli/libexec/lib/python3/site-packages' At first I thought it was the dot in python3.9 so I removed it but there seems to be something wrong with the import.

johnlabarge avatar Feb 20 '21 20:02 johnlabarge

@johnlabarge A bit late, but in case it helps anyone else… check which aws, view the file and make certain the shebang is pointing at awscli's bundled Python installation. You might also notice the wrong Python in the other lines in the backtrace of the ModuleNotFoundError.

Your problem might arise because the aws executable got rewritten, an easy mistake to make by doing pip install awscli-plugin-endpoint with the pip on your path instead of awscli's embedded one, and by leaving out --no-deps which will result in awscli (1.x) getting installed by pip, as a dependency…

I know the ModuleNotFoundError line refers to /usr/local/opt/awscli, so it leads one to think aws is using the right Python, but the error stems from cli_legacy_plugin_path.

Probable solution if it's a Homebrew setup:

$ pip3 uninstall awscli
$ brew reinstall awscli
$ /usr/local/opt/awscli/libexec/bin/pip install --no-deps awscli-plugin-endpoint

The need to redo this delicate dance correctly every time awscli gets a version update is about to drive me to doing it with a Dockerfile and using the image, instead of aws from Homebrew installation…

ches avatar May 11 '21 19:05 ches