为什么在 amazonlinux2 ami 上找不到 aws cli?

Why is the aws cli not found on amazonlinux2 ami?

我用于 Docker 主机的 AmazonLinux2 AMI 似乎没有安装 AWS CLI。日志中有来自尝试 运行 一个 aws 命令的用户数据脚本的错误:

/var/lib/cloud/instance/scripts/part-001: line 7: aws: command not found

然后我通过 SSH 连接到实例进行完整性检查,aws 肯定找不到:

[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

我认为 AWS CLI 默认安装在所有 AmazonLinux AMI 上?我不记得以前必须自己安装它。

这篇文章甚至说在 AmazonLinux2 上默认安装了 CLI v1:

AWS Docs Link

那么怎么可能在此库存 AMI 上找不到它呢?是否只有部分 AmazonLinux2 AMI 预安装了 CLI?作为参考,我正在使用这个 AMI:

amzn2-ami-minimal-hvm-2.0.20200917.0-x86_64-ebs (ami-0a6993b2978bd23cb)

来自 AWS 论坛上的 post

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.

如果你想要awscli,你可以安装它:

sudo yum install -y awscli

要安装最新版本的 awscli (v2),请参阅 this doc

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install