yawsso can't find the right awscli - amazon-web-services

I am trying to use yawsso to login to aws. I have awscliv2 installed by following the instructions here.
Unfortunately I also seem to have aws version 1 on my computer as well.
So when I try
yawsso login --profile my-profile --this -e
I get the response:
Required AWS CLI v2. Found aws-cli/1.27.62 Python/3.9.13 Darwin/21.6.0 botocore/1.29.62
But awscli2 --version returns:
2.2.0
AWS CLI v2 command: docker run -i --rm -v /Users/tomkealy/.aws:/root/.aws -v /Users/tomkealy/my-folder:/aws amazon/aws-cli
aws-cli/2.9.20 Python/3.9.11 Linux/5.10.47-linuxkit docker/x86_64.amzn.2 prompt/off
which aws returns /Users/tomkealy/opt/anaconda3/bin/aws
and aws --version returns
aws-cli/1.27.62 Python/3.9.13 Darwin/21.6.0 botocore/1.29.62
How do I fix this so that yawsso finds the version 2 of the aws-cli?
I have tried to uninstall aws via conda and brew. To no success.

I figured it out by uninstalling awscli
pip uninstall awscli -y
which meant that which aws now pointed to
/usr/local/bin/aws
but aws --version now errored:
-bash: /Users/tomkealy/opt/anaconda3/bin/aws: No such file or directory
and I fixed THAT with
export PATH=$PATH:$HOME/aws-cli
now which aws gives
/usr/local/bin/aws
and aws --version prints
aws-cli/2.9.20 Python/3.11.1 Darwin/21.6.0 source/x86_64 prompt/off

Related

Why is the aws cli not found on amazonlinux2 ami?

The AmazonLinux2 AMI I am using for my Docker hosts does not appear to have the AWS CLI installed. The log has an error from the user data script that tries to run an aws command:
/var/lib/cloud/instance/scripts/part-001: line 7: aws: command not found
Then I connected with SSH to the instance for a sanity check, and aws is definitely not found:
[ec2-user#ip-X-X-X-X ~]$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
[ec2-user#ip-X-X-X-X ~]$ aws --version
-bash: aws: command not found
I thought the AWS CLI was installed by default on all AmazonLinux AMIs? I don't remember ever having to install it myself before.
This article even says that the CLI v1 is installed by default on AmazonLinux2:
AWS Docs Link
So how is it possible that it's not found on this stock AMI? Do only some of the AmazonLinux2 AMIs have the CLI pre-installed? For reference, I am using this AMI:
amzn2-ami-minimal-hvm-2.0.20200917.0-x86_64-ebs (ami-0a6993b2978bd23cb)
From this post on AWS forum:
Minimal has a smaller set of packages installed by default. For example, a lot of AWS specific packages are installed on the default for easy integration to other AWS services. The minimal do not have these installed. This gives a much lower footprint for those who are not directly interacting with other AWS services, or who want to cherry-pick which ones they install.
If you want awscli, you can install it:
sudo yum install -y awscli
to install the latest version of the awscli (v2) see this doc
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

s3 intelligent tiering, getting storage-class invalid choice at CLI

Update - how to upgrade aws cli? my attempts failed.
I get the following.
I've tried different regions and intelligent tiering works ok in the management console UI. But using the CLI I get:
$ aws s3 cp aws_aliases.sh --storage-class INTELLIGENT_TIERING s3://snap2web1
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument --storage-class: Invalid choice, valid choices are:
STANDARD | REDUCED_REDUNDANCY
STANDARD_IA
I tried updating my aws cli but that didn't help:
$ aws --version
aws-cli/1.14.44 Python/3.6.8 Linux/4.15.0-65-generic botocore/1.8.48
$ pip install --upgrade awscli
Collecting awscli
...
$ aws --version
aws-cli/1.14.44 Python/3.6.8 Linux/4.15.0-65-generic botocore/1.8.48
I tried upgrading my aws version from 1.44 to 1.61 but
$ pip install --upgrade awscli
didn't do it.
I then removed awscli and reinstalled it but I still get 1.44
How to upgrade ?
Update: After update (sudo snap install aws-cli --classic):
$ aws --version
aws-cli/1.16.148 Python/3.6.7 Linux/4.15.0-65-generic botocore/1.12.138
You may be using an outdated version of the cli, please upgrade. What version are you using?
aws --version
Support for intelligent tier was added in version 1.16.61 of the aws cli as can be seen in the Github project.

AWS CLI(aws rds) Unknown Option : --cloudwatch-logs-export-configuration

I am trying to run aws cli to enable Postgres RDS log files export to cloudwatch(for longer retention and dashboards)
The command I ran :
aws rds modify-db-instance --db-instance-identifier --cloudwatch-logs-export-configuration '{"EnableLogTypes":["postgres", "upgrade"]}'
I get error :
Unknown options: --cloudwatch-logs-export-configuration
In AWS documentation this is a suggested command, but in 'aws help' this option is not documented.
Try updating the CLI version
1.11.139 is the latest version of awscli
if you are using pip, proceed with pip (or) pip3 install awscli --upgrade

Trying to upload a dockerfile to aws ecr

I'm trying to upload a dockerfile to AWS's ECR Service.
But when I issue the command
aws ecr get-login --no-include-email --region us-east-2
I get an error saying the host is down
'Connection aborted.', error(64, 'Host is down')
I'm using aws on a Mac
aws-cli/1.15.8 Python/2.7.10 Darwin/17.5.0 botocore/1.10.8
I tried to install python3 as indicated in the aws-docs, but it fails miserably with several errors. Python is always pointing to the Apple default install (in /usr/bin/python).
I tried about a dozen solutions from the web (including installing it via homebrew) - none of them helped.
I had to download the aws installer directly from amazon's servers, which worked:
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Any ideas?
[EDIT]
I'm actually still interested, why this all happens, but in the meantime, I abandoned AWS and switched to IBM-Bluemix. Deploying a Node-JS app was a breeze and took 5 minutes.

Unable to push docker images into AWS ECR from Windows 10

When I try to execute this command:
> aws ecr get-login --no-include-email --region us-east-1
I keep getting the error message:
> Unknown options: --no-include-email
I followed the instructions here: http://docs.aws.amazon.com/cli/latest/userguide/installing.html
to update my aws cli to the latest version:
> pip install awscli --upgrade --user
but the problem persists.
I am completely blocked, as there's no other way that I can use to push my docker images to Amazon ECR.
My environment is the following:
Windows 10 Pro
Version 1607
64 bits
aws-cli/1.11.89 Python/2.7.9 Windows/8 botocore/1.5.52
Docker version 17.06.0-ce, build 02c1d87
I found a workaround which was to just use the regular command:
> ecr get-login --region us-east-1
And then I removed the part:
>...-e none...
from the docker login command that was generated and ran it like that and I was able to login into my aws ecr repositories.
If you get rid of the email option, you might have a return line including a ''-e none'' that you dont want you can sed it
aws ecr get-login --youroptions | sed 's/\-e none//g'