Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(compat): install AWS CLI v2 in the compat image so AWS_ENDPOINT_URL is honored (#2315)

MakerYuichi9fda5f5919c8
diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml
index c1b90217fd..f6941934ee 100644
--- a/.github/workflows/compatibility.yml
+++ b/.github/workflows/compatibility.yml
@@ -6,6 +6,7 @@ on:
- 'src/**'
- 'pom.xml'
- 'docker/Dockerfile.native-package'
+ - 'docker/Dockerfile.compat'
- 'docker/entrypoint.sh'
- 'docker/localstack-parity.sh'
- 'compatibility-tests/**'
@@ -19,6 +20,66 @@ concurrency:
cancel-in-progress: true
jobs:
+ compat-aws-cli-shim:
+ name: compat / aws CLI endpoint resolution
+ runs-on: ubuntu-24.04-arm
+ timeout-minutes: 10
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
+
+ - name: Build compat image
+ uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
+ with:
+ context: .
+ file: docker/Dockerfile.compat
+ build-args: VERSION=latest
+ load: true
+ tags: floci-compat-shim-test
+ cache-from: type=gha,scope=compat-shim
+ cache-to: type=gha,scope=compat-shim,mode=max
+
+ - name: Unflagged aws sqs call routes to AWS_ENDPOINT_URL
+ run: |
+ out=$(docker run --rm --entrypoint sh floci-compat-shim-test -c \
+ "aws sqs create-queue --queue-name smoke-test 2>&1" || true)
+ echo "$out"
+ echo "$out" | grep -q "localhost:4566" \
+ || { echo "::error::unflagged aws call did not target localhost:4566"; exit 1; }
+ echo "$out" | grep -qi "queue.amazonaws.com\|InvalidClientTokenId" \
+ && { echo "::error::unflagged aws call reached real AWS endpoint"; exit 1; }
+ exit 0
+
+ - name: AWS_ENDPOINT_URL_SQS alone routes correctly
+ run: |
+ out=$(docker run --rm --entrypoint sh -e AWS_ENDPOINT_URL= \
+ -e AWS_ENDPOINT_URL_SQS=http://localhost:4566 \
+ floci-compat-shim-test -c \
+ "aws sqs create-queue --queue-name smoke-test-service-override 2>&1" || true)
+ echo "$out"
+ echo "$out" | grep -q "localhost:4566" \
+ || { echo "::error::AWS_ENDPOINT_URL_SQS was not honored"; exit 1; }
+ echo "$out" | grep -qi "queue.amazonaws.com\|InvalidClientTokenId" \
+ && { echo "::error::AWS_ENDPOINT_URL_SQS call reached real AWS endpoint"; exit 1; }
+ exit 0
+
+ - name: Explicit --endpoint-url before the subcommand overrides AWS_ENDPOINT_URL
+ run: |
+ out=$(docker run --rm --entrypoint sh floci-compat-shim-test -c \
+ "AWS_ENDPOINT_URL=http://example.com aws --endpoint-url http://other.example.com sqs list-queues 2>&1" || true)
+ echo "$out"
+ echo "$out" | grep -q "other.example.com" \
+ || { echo "::error::pre-subcommand --endpoint-url flag was not honored over AWS_ENDPOINT_URL"; exit 1; }
+
+ - name: Explicit --endpoint-url after the subcommand overrides AWS_ENDPOINT_URL
+ run: |
+ out=$(docker run --rm --entrypoint sh floci-compat-shim-test -c \
+ "AWS_ENDPOINT_URL=http://example.com aws sqs list-queues --endpoint-url http://other.example.com 2>&1" || true)
+ echo "$out"
+ echo "$out" | grep -q "other.example.com" \
+ || { echo "::error::post-subcommand --endpoint-url flag was not honored over AWS_ENDPOINT_URL"; exit 1; }
+
build-native:
name: Build native floci image
runs-on: ubuntu-24.04-arm
diff --git a/docker/Dockerfile.compat b/docker/Dockerfile.compat
index 7a5b177429..d741db2056 100644
--- a/docker/Dockerfile.compat
+++ b/docker/Dockerfile.compat
@@ -17,10 +17,38 @@ ENV AWS_ACCESS_KEY_ID=test
ENV AWS_SECRET_ACCESS_KEY=test
ENV AWS_ENDPOINT_URL="http://localhost:4566"
ENV AWS_CONFIG_FILE=/etc/floci/aws/config
+ENV AWS_PAGER=""
+# AWS CLI v2. v1 (the only version pip3 install awscli can give you) resolves
+# a fixed set of services (SQS, RDS, DocDB, Neptune, EMR, Health) through
+# awscli/customizations/overridesslcommonname.py, which forces the real AWS
+# endpoint whenever no --endpoint-url flag is passed on the command line —
+# no environment variable, including AWS_ENDPOINT_URL and the per-service
+# AWS_ENDPOINT_URL_<SERVICE> overrides, can redirect it (aws/aws-cli#8737).
+# v2 has no equivalent override and resolves every service through the
+# normal endpoint chain, so AWS_ENDPOINT_URL alone is sufficient.
+#
+# v1 also entered maintenance mode 2026-07-15 (EOL 2027-07-15), so this is
+# needed regardless of the endpoint-resolution bug.
+#
+# cli_binary_format has no env var in v2 (its provider chain is config-file,
+# then a base64 constant), so blob params default to base64 here, same as
+# a v2 install against real AWS. A hook passing raw bytes (e.g.
+# aws lambda invoke --payload) needs --cli-binary-format raw-in-base64-out.
+ARG AWSCLI_VERSION=2.36.24
USER root
-RUN microdnf install -y --nodocs python3 python3-pip \
- && pip3 install --no-cache-dir awscli boto3 \
+RUN microdnf install -y --nodocs python3 python3-pip unzip \
+ && pip3 install --no-cache-dir boto3 \
+ && case "$(uname -m)" in \
+ x86_64) arch=x86_64 ;; \
+ aarch64) arch=aarch64 ;; \
+ *) echo "unsupported arch: $(uname -m)" >&2; exit 1 ;; \
+ esac \
+ && curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${arch}-${AWSCLI_VERSION}.zip" -o /tmp/awscliv2.zip \
+ && unzip -q /tmp/awscliv2.zip -d /tmp \
+ && /tmp/aws/install --bin-dir /usr/bin --install-dir /usr/local/aws-cli \
+ && rm -rf /tmp/awscliv2.zip /tmp/aws \
+ && microdnf remove -y unzip \
&& microdnf clean all \
&& rm -rf /root/.cache/pip
@@ -36,4 +64,4 @@ RUN mkdir -p /etc/localstack/init/boot.d /etc/localstack/init/start.d /etc/local
/etc/floci/init/boot.d /etc/floci/init/start.d /etc/floci/init/ready.d \
&& chown -R 1001:root /etc/localstack /etc/floci
-USER 1001
+USER 1001
\ No newline at end of file