aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.54k stars 4.13k forks source link

[v2] Distribute binaries for alpine / musl libc #4685

Closed jordanst3wart closed 1 year ago

jordanst3wart commented 4 years ago
docker run -it --rm docker:latest sh
wget "https://d1vvhvl2y92vvt.cloudfront.net/awscli-exe-linux-x86_64.zip" -O "awscliv2.zip"
# curl not installed
unzip awscliv2.zip
./aws/install
# sudo not install

Errors with:

/ # ./aws/install
./aws/install: line 78: /aws/dist/aws2: not found
You can now run: /usr/local/bin/aws2 --version
/ # aws2
sh: aws2: not found
vsimon commented 3 years ago

Based off @blagerweij glibc solution, I've started using this that works with the latest alpine image (not just 3.13) and can also install a specific awscli version (not just the latest)

Dockerfile:

FROM alpine:3.14.2

ENV AWSCLI_VERSION=2.2.41
ENV GLIBC_VER=2.31-r0

RUN apk add --update --no-cache \
  groff

RUN apk add --no-cache --virtual .dependencies binutils curl \
    && 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 \
    && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-i18n-${GLIBC_VER}.apk \
    && apk add --no-cache --virtual .glibc \
        glibc-${GLIBC_VER}.apk \
        glibc-bin-${GLIBC_VER}.apk \
        glibc-i18n-${GLIBC_VER}.apk \
    && /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 \
    && curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWSCLI_VERSION}.zip -o awscliv2.zip \
    && unzip awscliv2.zip \
    && aws/install \
    && rm -rf \
        awscliv2.zip \
        aws \
        /usr/local/aws-cli/v2/*/dist/aws_completer \
        /usr/local/aws-cli/v2/*/dist/awscli/data/ac.index \
        /usr/local/aws-cli/v2/*/dist/awscli/examples \
        glibc-*.apk \
    && apk del --purge .dependencies

❯ docker build -t awscli-test .
❯ docker run -it awscli-test sh
/ # aws --version
aws-cli/2.2.41 Python/3.8.8 Linux/5.10.47-linuxkit exe/x86_64.alpine.3 prompt/off
Tzrlk commented 2 years ago

Just to add another workaround to the mix, adding gcompat lets the binary run fine, and with groff the help displays. Still not alpine native, but a hell of a lot simpler than installing all of glibc.

volphy commented 2 years ago

@Tzrlk It would be a good workaround but unfortunately it does not work for everyone.

I have installed both gcompat and groff packages but I still cannot run the latest AWS CLI v2 and it ends with the following error message: ImportError: Error relocating /usr/local/aws-cli/v2/dist/_awscrt.cpython-38-x86_64-linux-gnu.so: pthread_attr_setaffinity_np: symbol not found

Am I missing something more in my Alpine Linux installation?

Tzrlk commented 2 years ago

Hmm. I guess something else I'm pulling in must be getting it to work. I suspect it's Java, but I remember running it on a pre-java build step. I'll check in the morning and see if I can make it break.

freeqaz commented 2 years ago

I just wanted to bump this -- I'm seeing the same error as @volphy. I even tried running this from a Java container with FROM openjdk:17-alpine and the error persists, so it doesn't seem like it's Java.

It'd be awesome to get this working, if it's possible!

blagerweij commented 2 years ago

@freeqaz just take a look at my earlier post, or check this SO article: https://stackoverflow.com/questions/60298619/awscli-version-2-on-alpine-linux/61268529#61268529 Some Java images (e.g. adoptopenjdk) include the glibc libs for alpine, hence they also work. But if your objective is getting a lean image, you should not install Java unless you really need to. If you need Java, you could checkout this page: https://github.com/team-carepay/openjdk-docker It contains several images including JDK 8, 11 and 17

pdefreitas commented 2 years ago

I've tested Alpine 3.15 with gcompat and groff packages installed and it works perfectly with version 2.1.39 of AWS CLI. Above that you get pthread_attr_setaffinity_np: symbol not found just like other people mentioned in here, meaning that something added/changed in the meanwhile breaks glibc compatibility layer that gcompat package can provide. In the meanwhile I'll probably stick with pip until #6352.

christhomas commented 2 years ago

Based off @blagerweij glibc solution, I've started using this that works with the latest alpine image (not just 3.13) and can also install a specific awscli version (not just the latest)

Dockerfile:

FROM alpine:3.14.2

ENV AWSCLI_VERSION=2.2.41
ENV GLIBC_VER=2.31-r0

RUN apk add --update --no-cache \
  groff

RUN apk add --no-cache --virtual .dependencies binutils curl \
    && 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 \
    && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-i18n-${GLIBC_VER}.apk \
    && apk add --no-cache --virtual .glibc \
        glibc-${GLIBC_VER}.apk \
        glibc-bin-${GLIBC_VER}.apk \
        glibc-i18n-${GLIBC_VER}.apk \
    && /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 \
    && curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWSCLI_VERSION}.zip -o awscliv2.zip \
    && unzip awscliv2.zip \
    && aws/install \
    && rm -rf \
        awscliv2.zip \
        aws \
        /usr/local/aws-cli/v2/*/dist/aws_completer \
        /usr/local/aws-cli/v2/*/dist/awscli/data/ac.index \
        /usr/local/aws-cli/v2/*/dist/awscli/examples \
        glibc-*.apk \
    && apk del --purge .dependencies
❯ docker build -t awscli-test .
❯ docker run -it awscli-test sh
/ # aws --version
aws-cli/2.2.41 Python/3.8.8 Linux/5.10.47-linuxkit exe/x86_64.alpine.3 prompt/off

Amazing! Thanks mate, it works great!

samypr100 commented 2 years ago

Updated previous PyInstaller solution #4685 (comment) . Installing both make and cmake seems to get past that awscrt error.

FROM python:3-alpine3.13 AS installer

ENV AWSCLI_VERSION=2.2.0

RUN apk add --no-cache \
    gcc \
    git \
    libc-dev \
    libffi-dev \
    openssl-dev \
    py3-pip \
    zlib-dev \
    make \
    cmake

RUN git clone --recursive  --depth 1 --branch ${AWSCLI_VERSION} --single-branch https://github.com/aws/aws-cli.git

WORKDIR /aws-cli

# Follow https://github.com/six8/pyinstaller-alpine to install pyinstaller on alpine
RUN pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir pycrypto \
    && git clone --depth 1 --single-branch --branch v$(grep PyInstaller requirements-build.txt | cut -d'=' -f3) https://github.com/pyinstaller/pyinstaller.git /tmp/pyinstaller \
    && cd /tmp/pyinstaller/bootloader \
    && CFLAGS="-Wno-stringop-overflow -Wno-stringop-truncation" python ./waf configure --no-lsb all \
    && pip install .. \
    && rm -Rf /tmp/pyinstaller \
    && cd - \
    && boto_ver=$(grep botocore setup.cfg | cut -d'=' -f3) \
    && git clone --single-branch --branch v2 https://github.com/boto/botocore /tmp/botocore \
    && cd /tmp/botocore \
    && git checkout $(git log --grep $boto_ver --pretty=format:"%h") \
    && pip install . \
    && rm -Rf /tmp/botocore  \
    && cd -

RUN sed -i '/botocore/d' requirements.txt \
    && scripts/installers/make-exe

RUN unzip dist/awscli-exe.zip \
    && ./aws/install --bin-dir /aws-cli-bin

FROM alpine:3.13

RUN apk --no-cache add groff

COPY --from=installer /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=installer /aws-cli-bin/ /usr/local/bin/

Awesome! @vsimon

I wanted to add a more recent update as this Dockerfile was from Apr 2021.

Since then the latest versions of PyInstaller have provide the ability to compile the bootloader on the fly via an environment variable PYINSTALLER_COMPILE_BOOTLOADER (see their changelog). On a same note, as of version 4.6 they added proper alpine wheels so shouldn't get symbol not found anymore when generating an exe. This greatly helps simplify the build process as you don't have to re-build PyInstaller from source anymore.

Here's an example docker file that I've been using to force using a more recent version of PyInstaller to generate an alpine awscli-exe.zip without the need for gcompat or glibc.

FROM python:3.9-alpine as installer

RUN set -ex; \
    apk add --no-cache \
    git unzip groff \
    build-base libffi-dev cmake

ENV AWS_CLI_VERSION=2.5.4
RUN set -eux; \
    mkdir /aws; \
    git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git /aws; \
    cd /aws; \
    sed -i'' 's/PyInstaller.*/PyInstaller==4.10/g' requirements-build.txt; \
    python -m venv venv; \
    . venv/bin/activate; \
    ./scripts/installers/make-exe

RUN set -ex; \
    unzip /aws/dist/awscli-exe.zip; \
    ./aws/install --bin-dir /aws-cli-bin; \
    /aws-cli-bin/aws --version

Edit (09/14/2022): Per commit b510588d062f5a7fc66ad16080c3abc5159f17a9, AWS CLI Version >= 2.7.30 will require PyInstaller >= 5.3. Hence, you can either remove sed -i'' 's/PyInstaller.*/PyInstaller==4.10/g' requirements-build.txt; \ from the example above or change 4.10 to be 5.3 or above. Thanks @blagerweij for confirming this.

jurgen-weber-deltatre commented 2 years ago

Tis is now failing on 2.7.31 and 2.7.30

  inflating: aws/dist/lib-dynload/_sqlite3.cpython-39-x86_64-linux-gnu.so
  inflating: aws/dist/lib-dynload/_pickle.cpython-39-x86_64-linux-gnu.so
  inflating: aws/dist/lib-dynload/unicodedata.cpython-39-x86_64-linux-gnu.so
+ ./aws/install --bin-dir /aws-cli-bin
Traceback (most recent call last):
  File "aws", line 19, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/clidriver.py", line 20, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/session.py", line 27, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/client.py", line 16, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/waiter.py", line 17, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/docs/__init__.py", line 15, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/docs/service.py", line 15, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/docs/paginator.py", line 13, in <module>
ImportError: cannot import name 'xform_name' from 'botocore' (unknown location)
[12] Failed to execute script 'aws' due to unhandled exception!
You can now run: /aws-cli-bin/aws --version
+ /aws-cli-bin/aws --version
Traceback (most recent call last):
  File "aws", line 19, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/clidriver.py", line 20, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/session.py", line 27, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/client.py", line 16, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/waiter.py", line 17, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/docs/__init__.py", line 15, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/docs/service.py", line 15, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
  File "awscli/botocore/docs/paginator.py", line 13, in <module>
ImportError: cannot import name 'xform_name' from 'botocore' (unknown location)
[1] Failed to execute script 'aws' due to unhandled exception!

Looking at a few places I use this, the last successful version/build is:

$ aws --version
aws-cli/2.7.27 Python/3.9.13 Linux/5.10.130 exe/x86_64.alpine.3 prompt/off

I have tried running through every versiuon and 2.7.28 and 2.7.29 give me a new error

+ ./aws/install --bin-dir /aws-cli-bin

No module named 's3transfer.crt'
You can now run: /aws-cli-bin/aws --version
+ /aws-cli-bin/aws --version

No module named 's3transfer.crt'
The command '/bin/sh -c set -ex;     unzip /aws/dist/awscli-exe.zip;     ./aws/install --bin-dir /aws-cli-bin;     /aws-cli-bin/aws --version' returned a non-zero code: 255

Which makes 2.7.27 the last stable/working version.

blagerweij commented 2 years ago

I encountered the same. Everything was fine up to 2.7.29. Things started to break since 2.7.30 and 2.7.31. Version 2.7.32 seems to have fixed the issue, although I'm still clueless on the botocore xform_name error message, and how the changes could affect this. PyInstaller has been upgraded to version 5.2, probably that's the root cause. But I can't find any obvious bugfix in 2.7.32, yet it seems to work. 🤷 On a more positive note: Since the main branch has updated PyInstaller to 5.2, we can remove the 'sed' line where the version is changed.

Hazzard17h commented 1 year ago

Based off @blagerweij glibc solution, I've started using this that works with the latest alpine image (not just 3.13) and can also install a specific awscli version (not just the latest)

Dockerfile:

FROM alpine:3.14.2

ENV AWSCLI_VERSION=2.2.41
ENV GLIBC_VER=2.31-r0

RUN apk add --update --no-cache \
  groff

RUN apk add --no-cache --virtual .dependencies binutils curl \
    && 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 \
    && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-i18n-${GLIBC_VER}.apk \
    && apk add --no-cache --virtual .glibc \
        glibc-${GLIBC_VER}.apk \
        glibc-bin-${GLIBC_VER}.apk \
        glibc-i18n-${GLIBC_VER}.apk \
    && /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 \
    && curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWSCLI_VERSION}.zip -o awscliv2.zip \
    && unzip awscliv2.zip \
    && aws/install \
    && rm -rf \
        awscliv2.zip \
        aws \
        /usr/local/aws-cli/v2/*/dist/aws_completer \
        /usr/local/aws-cli/v2/*/dist/awscli/data/ac.index \
        /usr/local/aws-cli/v2/*/dist/awscli/examples \
        glibc-*.apk \
    && apk del --purge .dependencies
❯ docker build -t awscli-test .
❯ docker run -it awscli-test sh
/ # aws --version
aws-cli/2.2.41 Python/3.8.8 Linux/5.10.47-linuxkit exe/x86_64.alpine.3 prompt/off

I found that this also works for:

FROM alpine:3.17.2

ENV AWSCLI_VERSION=2.10.2
ENV GLIBC_VER=2.34-r0

But not with GLIBC_VER=2.35-r0, and must add --force-overwrite in the apk add command that install glibc due to this https://github.com/sgerrand/alpine-pkg-glibc/issues/185#issuecomment-1245449995

blagerweij commented 1 year ago

This thread is quite outdated: AWS CLI v2.10 has now proper support for Alpine / libmusl :

ARG ALPINE_VERSION=3.17
FROM python:3.10-alpine${ALPINE_VERSION} as builder

ARG AWS_CLI_VERSION=2.10.0
RUN apk add --no-cache git unzip groff build-base libffi-dev cmake
RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git

WORKDIR aws-cli
RUN ./configure --with-install-type=portable-exe --with-download-deps
RUN make
RUN make install

# reduce image size: remove autocomplete and examples
RUN rm -rf \
    /usr/local/lib/aws-cli/aws_completer \
    /usr/local/lib/aws-cli/awscli/data/ac.index \
    /usr/local/lib/aws-cli/awscli/examples
RUN find /usr/local/lib/aws-cli/awscli/data -name completions-1*.json -delete
RUN find /usr/local/lib/aws-cli/awscli/botocore/data -name examples-1.json -delete
RUN (cd /usr/local/lib/aws-cli; for a in *.so*; do test -f /lib/$a && rm $a; done)

# build the final image
FROM alpine:${ALPINE_VERSION}
COPY --from=builder /usr/local/lib/aws-cli/ /usr/local/lib/aws-cli/
RUN ln -s /usr/local/lib/aws-cli/aws /usr/local/bin/aws

As you can see, we can use 'configure', 'make' and 'make install'. The above Dockerfile removes some 'nice to have' stuff such as autocomplete, documentation, etc.

skyzyx commented 1 year ago

That's great! I was waiting for someone from AWS to update this thread appropriately. I haven't touched this for a while since I was still waiting, but let me try rebuilding.

For cases like mine where we build and package things in CI, push them into a Linux repo, then have users install from the Linux repo — Does anyone know off the top of their head of there are make or ./configure changes that allow building in a different path/directory from where it will ultimately be installed?

IIRC, there was a time when this was not supported by this project. (But TBH, I might be thinking of something else.)

jonemo commented 1 year ago

The AWS CLI team recently published documentation for building CLI v2 from source here: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-source-install.html This contains a section "Alpine Linux container".

samypr100 commented 1 year ago

Thanks for the update, it works nicely when building from source now without any gimmicks.

Since the OP asked for pre-built distribution of alpine binaries, are there any future plans to get an official distribution in alpine?

tuananh commented 1 year ago

The AWS CLI team recently published documentation for building CLI v2 from source here: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-source-install.html This contains a section "Alpine Linux container".

I just tested this. it works, however the image is 380MB. the docs says it's abt 150MB. 380MB is on par with the official amazonlinux2 based image (386MB)

I only change version to latest (2.11.4) because the old link is broken.

blagerweij commented 1 year ago

Please check the SO answer here: https://stackoverflow.com/a/61268529/1704634 The compressed image size is about 36Mb, uncompressed about 136Mb with Alpine 3.17 / Python 3.11. This is assuming you're using the 'portable-exe' option, otherwise you're pulling in a bunch of Python3 dependencies.

Using Alpine 3.15 and Python 3.10 you can save a bit more (size is 108Mb). If you're really desperate to reduce the image size, you could consider to only keep the botocore data-files for the most commonly used services (ec2, s3, etc), since the botocore folder is about 70Mb. But I would recommend against doing that. But removing auto_completer and the examples helps a bit.

Regarding the alpine package: Please see this commit: https://gitlab.alpinelinux.org/alpine/aports/-/commit/aa039cf358500ac471ba9f82529dba0c0fdc2887

Support is coming, although the Alpine devs decided to use the Python3 dependencies instead of using the portable-exe. The portable-exe is about 100Mb, using Python3 dependencies adds about 300Mb to your image.

isuftin commented 1 year ago

I also followed https://docs.aws.amazon.com/cli/latest/userguide/getting-started-source-install.html and it works for more recent versions..

FROM our.registry/alpine-python:3.10 AS builder

ARG INSTALL_VERSION=2.11.5

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

WORKDIR /target

# Grab install dependencies
RUN apk add --no-cache \
  curl~=7.83 \
  make~=4.3 \
  cmake~=3.23 \
  gcc~=11.2.1 \
  g++~=11.2.1 \
  libc-dev~=0.7.2 \
  libffi-dev~=3.4.2 \
  openssl-dev~=1.1.1 \
  \
  && curl https://awscli.amazonaws.com/awscli-${INSTALL_VERSION}.tar.gz | tar -xz --strip-components 1 \
  && ./configure --with-download-deps --with-install-type=portable-exe \
  && make && make install \
  \
  && rm -rf \
  /usr/local/lib/aws-cli/aws_completer \
  /usr/local/lib/aws-cli/awscli/data/ac.index \
  /usr/local/lib/aws-cli/awscli/examples && \
  find /usr/local/lib/aws-cli/awscli/data -name 'completions-1*.json' -delete && \
  find /usr/local/lib/aws-cli/awscli/botocore/data -name 'examples-1.json' -delete

This works fine. However, if I try 2.9.23, that tar.gz isn't found @ https://awscli.amazonaws.com

So this has me a bit worried that this process is a bit fragile since we do rebuild historic images every now and again to patch OS level vulnerabilities while keeping the version the same.

Anyone have any thoughts on where a perm base for the source for historic versions might be found?

vsimon commented 1 year ago

One thought is that support for Alpine / libmusl started happening with v2.10 going forward so I wouldn't think 2.9.x and lower would be supported or these tar.gz files would be available in the same manner as the new versions.

blagerweij commented 1 year ago

From version v2.9.x they started to support Alpine/libmusl, however since v2.10 the build-system has been changed to use configure / make / make install, and use Python libraries (next to portable-exe).

Regarding the source tar.gz files: you could consider to use the git tags: RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git

isuftin commented 1 year ago

@vsimon - That makes sense. In-house, we're deprecating 2.9 in April so I guess we'll continue to build as we've been building w/ glibc in Alpine until then. Once we move off of 2.9, we'll switch our Dockerfiles to using configure/make/make install. What I didn't want was a separate build process for 2.9 and then everything else.

@blagerweij - I did try that last week, but the source in github doesn't contain the configure/make/make install content that I'm interested in. It contains the install binary. That's what we use today, pulling it down from https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${INSTALL_VERSION}.zip.

Thanks for both of your comments.

wsalles commented 1 year ago

for those who are still having issues (like I was) and are having to do the installation procedure using make install and so on to install aws-cli v2, know that we have already been available since July 7th the package of aws-cli version 2.13.0 in Alpine 3.18 : https://alpine.pkgs.org/3.18/alpine-community-x86_64/aws-cli-2.13.0-r0.apk.html

Build date: 2023-07-07 22:24:15
Git commit: 5c9b600aeb2eb1e6131cf47379ae2ffee5317933

So, you just need to do:

apk update
apk add aws-cli

or if you want to specific a version like me, use: apk add "aws-cli=2.13.0-r0"

output:

/ # apk add "aws-cli=2.13.0-r0"
(1/62) Installing libbz2 (1.0.8-r5)
(2/62) Installing libexpat (2.5.0-r1)
(3/62) Installing libffi (3.4.4-r2)
(4/62) Installing gdbm (1.23-r1)
(5/62) Installing xz-libs (5.4.3-r0)
(6/62) Installing libgcc (12.2.1_git20220924-r10)
(7/62) Installing libstdc++ (12.2.1_git20220924-r10)
(8/62) Installing mpdecimal (2.5.1-r2)
(9/62) Installing ncurses-terminfo-base (6.4_p20230506-r0)
(10/62) Installing libncursesw (6.4_p20230506-r0)
(11/62) Installing libpanelw (6.4_p20230506-r0)
(12/62) Installing readline (8.2.1-r1)
(13/62) Installing sqlite-libs (3.41.2-r2)
(14/62) Installing python3 (3.11.4-r0)
(15/62) Installing python3-pycache-pyc0 (3.11.4-r0)
(16/62) Installing pyc (0.1-r0)
(17/62) Installing py3-certifi (2023.5.7-r0)
(18/62) Installing py3-certifi-pyc (2023.5.7-r0)
(19/62) Installing py3-cparser (2.21-r2)
(20/62) Installing py3-cparser-pyc (2.21-r2)
(21/62) Installing py3-cffi (1.15.1-r3)
(22/62) Installing py3-cffi-pyc (1.15.1-r3)
(23/62) Installing py3-cryptography (40.0.2-r1)
(24/62) Installing py3-cryptography-pyc (40.0.2-r1)
(25/62) Installing py3-six (1.16.0-r6)
(26/62) Installing py3-six-pyc (1.16.0-r6)
(27/62) Installing py3-dateutil (2.8.2-r3)
(28/62) Installing py3-dateutil-pyc (2.8.2-r3)
(29/62) Installing py3-distro (1.8.0-r2)
(30/62) Installing py3-distro-pyc (1.8.0-r2)
(31/62) Installing py3-colorama (0.4.6-r3)
(32/62) Installing py3-colorama-pyc (0.4.6-r3)
(33/62) Installing py3-docutils (0.19-r4)
(34/62) Installing py3-docutils-pyc (0.19-r4)
(35/62) Installing py3-jmespath (1.0.1-r1)
(36/62) Installing py3-jmespath-pyc (1.0.1-r1)
(37/62) Installing py3-urllib3 (1.26.15-r1)
(38/62) Installing py3-urllib3-pyc (1.26.15-r1)
(39/62) Installing py3-wcwidth (0.2.6-r2)
(40/62) Installing py3-wcwidth-pyc (0.2.6-r2)
(41/62) Installing py3-prompt_toolkit (3.0.38-r1)
(42/62) Installing py3-prompt_toolkit-pyc (3.0.38-r1)
(43/62) Installing py3-ruamel.yaml.clib (0.2.7-r1)
(44/62) Installing py3-ruamel.yaml (0.17.32-r0)
(45/62) Installing py3-ruamel.yaml-pyc (0.17.32-r0)
(46/62) Installing aws-cli-pyc (2.13.0-r0)
(47/62) Installing py3-awscrt-pyc (0.16.24-r0)
(48/62) Installing python3-pyc (3.11.4-r0)
(49/62) Installing aws-c-common (0.8.23-r0)
(50/62) Installing aws-c-cal (0.6.0-r0)
(51/62) Installing aws-c-compression (0.2.17-r0)
(52/62) Installing s2n-tls (1.3.45-r0)
(53/62) Installing aws-c-io (0.13.28-r0)
(54/62) Installing aws-c-http (0.7.11-r0)
(55/62) Installing aws-c-sdkutils (0.1.11-r0)
(56/62) Installing aws-c-auth (0.7.0-r0)
(57/62) Installing aws-checksums (0.1.16-r0)
(58/62) Installing aws-c-event-stream (0.3.1-r0)
(59/62) Installing aws-c-mqtt (0.8.14-r0)
(60/62) Installing aws-c-s3 (0.3.13-r0)
(61/62) Installing py3-awscrt (0.16.24-r0)
(62/62) Installing aws-cli (2.13.0-r0)
Executing busybox-1.36.1-r0.trigger
OK: 175 MiB in 77 packages

/ # aws --version
aws-cli/2.13.0 Python/3.11.4 Linux/5.15.49-linuxkit-pr source/x86_64.alpine.3 prompt/off

/ # which aws
/usr/bin/aws

I hope I helped someone with this news 👍

jordanst3wart commented 1 year ago
apk update
apk add aws-cli

I feel like this issue can be closed now.

tim-finnigan commented 1 year ago

Thanks @jordanst3wart — closing this per comments above and will highlight this comment again for visibility:

The AWS CLI team recently published documentation for building CLI v2 from source here: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-source-install.html This contains a section "Alpine Linux container".

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.