Skip to content

Adding support for aws cli v2 #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions aws_cli.sh
Original file line number Diff line number Diff line change
@@ -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