Why is the aws cli not found on amazonlinux2 ami?

5.6k views Asked by At

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)

2

There are 2 answers

1
Marcin On BEST ANSWER

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
0
ALFmachine On

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