由于根据glibc编译的二进制文件与musl不兼容,AWS CLI V2 不能在Alpine Linux上运行,直接安装会出现如下的错误:
apk add --no-cache curl
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
./aws/install: line 78: /aws/dist/aws: not found
以下是最有效的方法
- 安装aws-cli 2.x版本
GLIBC_VER=2.31-r0
apk --no-cache add binutils curl jq
curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub
curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk
curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk
apk --no-cache add glibc-${GLIBC_VER}.apk glibc-bin-${GLIBC_VER}.apk
curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip
unzip awscliv2.zip
aws/install
apk --no-cache del binutils curl
rm glibc-${GLIBC_VER}.apk glibc-bin-${GLIBC_VER}.apk
rm -rf awscliv2.zip aws /var/cache/apk/*
#检查版本
aws --version
aws-cli/2.10.0 Python/3.9.11 Linux/5.10.109-104.500.amzn2.x86_64 exe/x86_64.alpine.3 prompt/off
- 没有版本要求,直接安装aws-cli 1.x版本
apk update
apk --no-cache add --update py-pip
pip3 install awscli
#检查版本
aws
Note: AWS CLI version 2, the latest major version of the AWS CLI, is now stable and recommended for general use. For more information, see the AWS CLI version 2 installation instructions at: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
设置环境变量
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_DEFAULT_REGION=us-west-2