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

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.

Related

yawsso can't find the right awscli

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

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

How to run `AWS sam` command on ubuntu?

I am using AWS sam to package and deploy my lambda functions. But I found the sam command doesn't work well in ubuntu linux.
Below is the output of sam package command from ubuntu-16.04. It looks like the command arguments error but the same command can be run on Mac. I don't know what wrong with this command.
$ sam package --template-file sam.yaml --s3-bucket mybucket --output-template-file packaged.yaml
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 operation: Invalid choice, valid choices are:
...
$ sam --version
SAM CLI, version 0.16.0
It turns out that the problem was that the awscli version was too old. Solved it by upgrading awscli since it is used underneath.

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

How to resolve this error on a Kubernetes Installation on AWS?

I'm trying to install Kubernetes (first time) on AWS according to this tutorial http://kubernetes.io/docs/getting-started-guides/aws/#prerequisites
I can use the AWS CLI but after running the following command:
export KUBERNETES_PROVIDER=aws; curl -sS https://get.k8s.io | bash
Then I get this error:
Unpacking kubernetes release v1.3.0
Creating a kubernetes on aws...
... Starting cluster in us-west-2a using provider aws
... calling verify-prereqs
... calling kube-up
Starting cluster using os distro: jessie
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument subcommand: Invalid choice, valid choices are:
list
Uploading to Amazon S3
+++ Staging server tars to S3 Storage: kubernetes-staging-a9b7435c8fc7b6c3d3e26fdd5b84aaae/devel
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --region: expected one argument
any help/insight appreciated..
I had the same issue; it turned out I had pip install aws not pip install awscli. After uninstalling aws and installing awscli I was good to go.
Seems region is missing from environment vars.
Below example is env vars for Singapore region
export KUBE_AWS_ZONE=ap-southeast-1a
export NUM_NODES=2
export MASTER_SIZE=t2.micro
export NODE_SIZE=t2.micro
export AWS_S3_REGION=ap-southeast-1
export AWS_S3_BUCKET=mudrii-kubernetes-artifacts
export KUBE_AWS_INSTANCE_PREFIX=k8s