When I attempt to use aws-shell to check my s3 bucket list I get this error:

my environment is [cloudshell-user@ip-10-0-***~]$ aws --version
aws-cli/2.2.43 Python/3.8.8 Linux/4.14.252-195.483.amzn2.x86_64 exec-env/CloudShell exe/x86_64.amzn.2 prompt/off
Is anything wrong with any of my Envir. verions? Pls advice
See below for recommended approach -or- keep reading for a fix for aws-shell.
aws-shell requires awscli version 1 to function correctly, otherwise you'll receive the cli_binary_format error. To work around this you can do the following in the cloudshell environment.
pip3 install --user -U awscli aws-shell boto3 --use-feature=2020-resolver --no-cache-dir
export PATH=/home/cloudshell-user/.local/bin/:$PATH
However, the better solution would be to use awscli version 2 and enable the auto prompt feature as described here https://github.com/aws/aws-cli/issues/5664
aws configure set cli_auto_prompt on
or
export AWS_CLI_AUTO_PROMPT=on
Then awscli version 2 will behave similarly to aws-shell, providing completion hints etc.
A really late reply but for those who come here, the issue is that somewhere boto3 adds AWS_DATA_PATH into the env. This confuses aws cli and causes the issue, I just created a copy of the env and removed the AWS_DATA_PATH. problem sorted.
env = os.environ
# Remove injected invalid awsdatapath
env.pop('AWS_DATA_PATH')
os.execvpe('aws',['aws', 's3', 'ls',env)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With