diff --git a/Dockerfile b/Dockerfile index a8e87ef..5a2aeb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,13 +64,16 @@ RUN . /envfile && echo $ARCH && \ mv /tmp/eksctl /usr/bin && \ chmod +x /usr/bin/eksctl -# Install awscli -# Temp fix to allow system-wide package installation: -# https://stackoverflow.com/a/76540031/3671801 -RUN apk add --update --no-cache py3-pip && \ - pip3 install --break-system-packages --upgrade pip setuptools && \ - pip3 install --break-system-packages awscli && \ - pip3 cache purge +# Install awscli v1 +RUN apk add --update --no-cache pipx && \ + pipx install awscli --global --suffix=v1 + +# Install awscli v2 +RUN apk add --update --no-cache aws-cli && \ + mv /usr/bin/aws /usr/local/bin/awsv2 + +# Add script to switch between aws cli v1 and v2 +COPY aws_cli.sh /usr/local/bin/aws # Install jq RUN apk add --update --no-cache jq yq diff --git a/README.md b/README.md index 1bb616d..1593170 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ kubernetes docker images with necessary tools - [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator) (latest version when run the build) - [eksctl](https://github.com/weaveworks/eksctl) (latest version when run the build) - [awscli v1](https://github.com/aws/aws-cli) (latest version when run the build) +- [awscli v2](https://github.com/aws/aws-cli/tree/v2) (latest version when run the build) + - To use awscli v2, set the env var `AWS_CLI=v2`: `docker run --rm -e AWS_CLI=v2 alpine/k8s aws --version` - [kubeseal](https://github.com/bitnami-labs/sealed-secrets) (latest version when run the build) - [krew](https://github.com/kubernetes-sigs/krew) (latest version when run the build) - [vals](https://github.com/helmfile/vals) (latest version when run the build) diff --git a/aws_cli.sh b/aws_cli.sh new file mode 100755 index 0000000..0c76197 --- /dev/null +++ b/aws_cli.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Run v1 or v2 of the aws cli based on env var +if [[ -n "$AWS_CLI" && ("$AWS_CLI" == "v2" || "$AWS_CLI" == "2") ]]; then + exec /usr/local/bin/awsv2 "$@" +else + exec /usr/local/bin/awsv1 "$@" +fi