Skip to content

Commit f5b46b7

Browse files
authored
Support aws cli v1 (#37)
* Update Dockerfile, entrypoint.sh, and test workflows for compatibility with Ubuntu 24.04 - Upgrade base image in Dockerfile to Ubuntu 24.04 and install python3-venv. - Modify entrypoint.sh to improve error handling and logging for AWS CLI installation. - Create a new Makefile for build and run commands. - Update GitHub Actions workflows to use Ubuntu 24.04 for all jobs. * Update test.yaml to use actions/cache@main for Docker layer caching - Changed the version of actions/cache from v2 to main in two places to ensure the latest features and fixes are utilized for caching Docker layers. * Update AWS CLI version in test.yaml to 1.41.8 for improved compatibility * Update error message in entrypoint.sh for AWS CLI v1 architecture support * fixed support for v1 * Update Dockerfile to use Python 3.12-slim base image and remove python3-venv installation
1 parent 8a25385 commit f5b46b7

File tree

4 files changed

+104
-14
lines changed

4 files changed

+104
-14
lines changed

.github/workflows/test.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
dispatch_test_action:
1111
name: Dispatch Test Action
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313
steps:
1414
- uses: actions/checkout@main
1515
- name: Workflow Dispatch Status
@@ -24,7 +24,7 @@ jobs:
2424
gh_token: ${{ secrets.GH_TOKEN }} # scope: repo + workflow
2525

2626
test_dirs:
27-
runs-on: ubuntu-22.04
27+
runs-on: ubuntu-24.04
2828
strategy:
2929
matrix:
3030
include:
@@ -61,7 +61,7 @@ jobs:
6161
sudo --preserve-env ./entrypoint.sh
6262
6363
test_x86:
64-
runs-on: ubuntu-22.04
64+
runs-on: ubuntu-24.04
6565
strategy:
6666
matrix:
6767
include:
@@ -72,7 +72,7 @@ jobs:
7272
- TEST_NAME: "Latest v1"
7373
AWS_CLI_VERSION: "1"
7474
- TEST_NAME: "Specific v1"
75-
AWS_CLI_VERSION: "1.32.19"
75+
AWS_CLI_VERSION: "1.41.8"
7676
- TEST_NAME: "No Input"
7777
name: Test amd64 ${{ matrix.TEST_NAME }} ${{ matrix.AWS_CLI_VERSION}}
7878
steps:
@@ -85,7 +85,7 @@ jobs:
8585
sudo --preserve-env ./entrypoint.sh
8686
8787
test_x64:
88-
runs-on: ubuntu-22.04
88+
runs-on: ubuntu-24.04
8989
strategy:
9090
matrix:
9191
include:
@@ -96,7 +96,7 @@ jobs:
9696
- TEST_NAME: "Latest v1"
9797
AWS_CLI_VERSION: "1"
9898
- TEST_NAME: "Specific v1"
99-
AWS_CLI_VERSION: "1.32.19"
99+
AWS_CLI_VERSION: "1.41.8"
100100
- TEST_NAME: "No Input"
101101
name: Test amd64 ${{ matrix.TEST_NAME }} ${{ matrix.AWS_CLI_VERSION}}
102102
steps:
@@ -109,7 +109,7 @@ jobs:
109109
sudo --preserve-env ./entrypoint.sh
110110
111111
test_amd64:
112-
runs-on: ubuntu-22.04
112+
runs-on: ubuntu-24.04
113113
strategy:
114114
matrix:
115115
include:
@@ -120,7 +120,7 @@ jobs:
120120
- TEST_NAME: "Latest v1"
121121
AWS_CLI_VERSION: "1"
122122
- TEST_NAME: "Specific v1"
123-
AWS_CLI_VERSION: "1.32.19"
123+
AWS_CLI_VERSION: "1.41.8"
124124
- TEST_NAME: "No Input"
125125
name: Test amd64 ${{ matrix.TEST_NAME }} ${{ matrix.AWS_CLI_VERSION}}
126126
steps:
@@ -134,7 +134,7 @@ jobs:
134134
135135
test_arm:
136136
# Supports only v2+
137-
runs-on: ubuntu-22.04
137+
runs-on: ubuntu-24.04
138138
strategy:
139139
matrix:
140140
include:
@@ -190,7 +190,7 @@ jobs:
190190
191191
test_arm64:
192192
# Supports only v2+
193-
runs-on: ubuntu-22.04
193+
runs-on: ubuntu-24.04
194194
strategy:
195195
matrix:
196196
include:

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM ubuntu:20.04
2-
RUN apt-get update -y && apt-get install -y wget unzip python3
1+
FROM python:3.12-slim
2+
RUN apt-get update -y && apt-get install -y wget unzip
33
WORKDIR /app/
44
COPY . .
55
ENTRYPOINT ["./entrypoint.sh"]

Makefile

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!make
2+
.ONESHELL:
3+
.EXPORT_ALL_VARIABLES:
4+
.PHONY: all $(MAKECMDGOALS)
5+
6+
UNAME := $(shell uname)
7+
UNAME_ARCH := $(shell uname -m)
8+
ROOT_DIR:=${CURDIR}
9+
BASH_PATH:=$(shell which bash)
10+
11+
# --- OS Settings --- START ------------------------------------------------------------
12+
# Windows
13+
ifneq (,$(findstring NT, $(UNAME)))
14+
_OS:=windows
15+
endif
16+
# macOS
17+
ifneq (,$(findstring Darwin, $(UNAME)))
18+
_OS:=macos
19+
endif
20+
21+
ifneq (,$(findstring Linux, $(UNAME)))
22+
_OS:=linux
23+
endif
24+
25+
# Architecture
26+
ifneq (,$(findstring arm64, $(UNAME_ARCH)))
27+
_ARCH:=arm64
28+
endif
29+
30+
ifneq (,$(findstring x86_64, $(UNAME_ARCH)))
31+
_ARCH:=amd64
32+
endif
33+
34+
_AWS_CLI_VERSION:=v2
35+
_AWS_CLI_ARCH:=amd64
36+
37+
ifndef AWS_CLI_VERSION
38+
AWS_CLI_VERSION:=${_AWS_CLI_VERSION}
39+
endif
40+
41+
ifndef AWS_CLI_ARCH
42+
AWS_CLI_ARCH:=${_AWS_CLI_ARCH}
43+
endif
44+
45+
46+
ifndef ARCH
47+
ARCH:=${_ARCH}
48+
endif
49+
50+
51+
# --- OS Settings --- END --------------------------------------------------------------
52+
53+
SHELL:=${BASH_PATH}
54+
55+
DOCKER_IMAGE_NAME:=install-aws-cli-action
56+
57+
# Removes blank rows - fgrep -v fgrep
58+
# Replace ":" with "" (nothing)
59+
# Print a beautiful table with column
60+
help: ## Print this menu
61+
@echo
62+
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's~:.* #~~' | column -t -s'#'
63+
@echo
64+
usage: help
65+
66+
67+
# To validate env vars, add "validate-MY_ENV_VAR"
68+
# as a prerequisite to the relevant target/step
69+
validate-%:
70+
@if [[ -z '${${*}}' ]]; then \
71+
echo 'ERROR: Environment variable $* not set' && \
72+
exit 1 ; \
73+
fi
74+
75+
76+
docker-build:
77+
docker build --platform linux/${ARCH} -t ${DOCKER_IMAGE_NAME} .
78+
79+
build: docker-build
80+
81+
docker-run:
82+
docker run --rm --platform linux/${ARCH} -it ${DOCKER_IMAGE_NAME} "${AWS_CLI_VERSION}" "${AWS_CLI_ARCH}"
83+
84+
run: docker-run

entrypoint.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ get_download_url(){
6161
provided_arch="$2"
6262
# v1
6363
if [[ "$provided_version" =~ ^1.*$ ]]; then
64-
[[ "$provided_arch" != "amd64" ]] && msg_error "AWS CLI v1 does not support ${_AWS_CLI_VERSION}"
64+
if [[ "$provided_arch" =~ ^(arm.*|aarch64)$ ]]; then
65+
echo "Provided arch ${provided_arch} is not supported for AWS CLI v1"
66+
return
67+
fi
6568
if [[ "$provided_version" = "1" ]]; then
6669
download_url="https://s3.amazonaws.com/aws-cli/awscli-bundle.zip"
6770
else
@@ -90,6 +93,7 @@ get_download_url(){
9093
}
9194

9295
set_download_tool(){
96+
msg_log "Setting download tool"
9397
# Default is "wget", fallback is "curl", fails otherwise
9498
if which wget 1>/dev/null; then
9599
_AWS_CLI_DOWNLOAD_TOOL="wget"
@@ -98,6 +102,7 @@ set_download_tool(){
98102
else
99103
msg_error "Both 'wget' and 'curl' are not installed"
100104
fi
105+
msg_log "Download tool set to ${_AWS_CLI_DOWNLOAD_TOOL}"
101106
}
102107

103108

@@ -155,7 +160,7 @@ install_aws_cli(){
155160
wait
156161
msg_log "Installing AWS CLI - ${provided_version}"
157162
if [[ "$provided_version" =~ ^1.*$ ]]; then
158-
./awscli-bundle/install -i "${_INSTALLROOTDIR}}/aws" -b "${_BINDIR}/aws"
163+
./awscli-bundle/install -i "${_INSTALLROOTDIR}/aws" -b "${_BINDIR}/aws"
159164
elif [[ "$provided_version" =~ ^2.*$ ]]; then
160165
local aws_path=""
161166
aws_path=$(which aws || true)
@@ -264,6 +269,7 @@ set_download_tool
264269

265270
# Set Download URL and check if file exists on server
266271
_AWS_CLI_DOWNLOAD_URL="${AWS_CLI_DOWNLOAD_URL:-"$(get_download_url "$_AWS_CLI_VERSION" "$_AWS_CLI_ARCH" 2>&1)"}"
272+
267273
[[ ! "$_AWS_CLI_DOWNLOAD_URL" =~ ^https://.* ]] && msg_error "$_AWS_CLI_DOWNLOAD_URL"
268274
check_version_exists "$_AWS_CLI_DOWNLOAD_URL"
269275

0 commit comments

Comments
 (0)