Skip to content

Commit 73001c5

Browse files
joe4devclaude
andcommitted
fix(ls-api): fix AWS_LAMBDA_FUNCTION_VERSION panic, deduplicate docker flags
Two changes: 1. Add AWS_LAMBDA_FUNCTION_VERSION (and --platform/--add-host) to a shared RIE_DOCKER_OPTS variable in the Makefile. smoke-test.sh was missing this env var, causing a startup panic in the RIE. RIE_DOCKER_OPTS uses deferred assignment (=) so $$LATEST survives to recipe expansion time. 2. Replace the duplicated docker_opts array in smoke-test.sh with a call to the new start-rie-detached Makefile target. Both start-rie and start-rie-detached now use the same RIE_DOCKER_OPTS, so env vars stay in sync automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c34792f commit 73001c5

2 files changed

Lines changed: 25 additions & 34 deletions

File tree

cmd/ls-api/Makefile

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@ INTEROP_PORT := 9563
77
RIE_BINARY := $(REPO_ROOT)/bin/aws-lambda-rie-$(ARCH)
88
LS_API_BIN := $(REPO_ROOT)/bin/ls-api
99

10-
.PHONY: build-rie build-ls-api start-mock start-rie success fail smoke-test
10+
# Common docker flags for start-rie and start-rie-detached.
11+
# Uses deferred assignment (=) so $$LATEST is not expanded until recipe time,
12+
# where Make reduces $$ -> $ before passing the line to the shell.
13+
RIE_DOCKER_OPTS = \
14+
--platform linux/amd64 \
15+
--add-host=host.docker.internal:host-gateway \
16+
-p $(INTEROP_PORT):$(INTEROP_PORT) \
17+
-v $(RIE_BINARY):/var/rapid/init:ro \
18+
-v $(THIS_MAKEFILE_DIR)/handler.py:/var/task/handler.py:ro \
19+
-e LOCALSTACK_RUNTIME_ENDPOINT=http://host.docker.internal:$(MOCK_PORT) \
20+
-e LOCALSTACK_RUNTIME_ID=test-runtime-id \
21+
-e AWS_LAMBDA_FUNCTION_TIMEOUT=30 \
22+
-e AWS_LAMBDA_FUNCTION_VERSION='$$LATEST' \
23+
-e AWS_LAMBDA_FUNCTION_MEMORY_SIZE=128 \
24+
-e AWS_REGION=us-east-1 \
25+
-e _HANDLER=handler.handler \
26+
--entrypoint /var/rapid/init
27+
28+
.PHONY: build-rie build-ls-api start-mock start-rie start-rie-detached success fail smoke-test
1129

1230
build-rie: ## Build the RIE Linux binary via Go cross-compilation (works on macOS)
1331
$(MAKE) -C $(REPO_ROOT) ARCH=$(ARCH) compile-lambda-linux
@@ -19,19 +37,10 @@ start-mock: ## Run the ls-api LocalStack endpoint mock natively (no Docker need
1937
go run $(THIS_MAKEFILE_DIR)
2038

2139
start-rie: build-rie ## Build and run the RIE inside a Docker Python Lambda container
22-
docker run --rm \
23-
-p $(INTEROP_PORT):$(INTEROP_PORT) \
24-
-v $(RIE_BINARY):/var/rapid/init:ro \
25-
-v $(THIS_MAKEFILE_DIR)/handler.py:/var/task/handler.py:ro \
26-
-e LOCALSTACK_RUNTIME_ENDPOINT=http://host.docker.internal:$(MOCK_PORT) \
27-
-e LOCALSTACK_RUNTIME_ID=test-runtime-id \
28-
-e AWS_LAMBDA_FUNCTION_TIMEOUT=30 \
29-
-e AWS_LAMBDA_FUNCTION_VERSION='$$LATEST' \
30-
-e AWS_LAMBDA_FUNCTION_MEMORY_SIZE=128 \
31-
-e AWS_REGION=us-east-1 \
32-
-e _HANDLER=handler.handler \
33-
--entrypoint /var/rapid/init \
34-
public.ecr.aws/lambda/python:3.12
40+
docker run --rm $(RIE_DOCKER_OPTS) public.ecr.aws/lambda/python:3.12
41+
42+
start-rie-detached: ## Start the RIE in detached mode; prints container ID (binaries must be pre-built)
43+
@docker run --detach $(RIE_DOCKER_OPTS) public.ecr.aws/lambda/python:3.12
3544

3645
success: ## Trigger a successful invocation via the mock's /success endpoint
3746
curl -sf http://localhost:$(MOCK_PORT)/success

cmd/ls-api/smoke-test.sh

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
88
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
99

1010
MOCK_PORT=48490
11-
INTEROP_PORT=9563
12-
RIE_BINARY="$REPO_ROOT/bin/aws-lambda-rie-x86_64"
1311
LS_API_BIN="$REPO_ROOT/bin/ls-api"
1412

1513
LOG_FILE=$(mktemp -t ls-api-smoke.XXXXXX)
@@ -55,25 +53,9 @@ MOCK_PID=$!
5553
for i in $(seq 1 10); do nc -z localhost $MOCK_PORT 2>/dev/null && break || sleep 1; done
5654

5755
# ---- start RIE ----
56+
# Docker flags are defined once in the Makefile (RIE_DOCKER_OPTS) and shared with start-rie.
5857
echo ">>> Starting RIE in Docker"
59-
60-
docker_opts=(
61-
--detach
62-
--platform linux/amd64
63-
--add-host=host.docker.internal:host-gateway
64-
-p "$INTEROP_PORT:$INTEROP_PORT"
65-
-v "$RIE_BINARY:/var/rapid/init:ro"
66-
-v "$SCRIPT_DIR/handler.py:/var/task/handler.py:ro"
67-
-e "LOCALSTACK_RUNTIME_ENDPOINT=http://host.docker.internal:$MOCK_PORT"
68-
-e "LOCALSTACK_RUNTIME_ID=smoke-test-runtime"
69-
-e "AWS_LAMBDA_FUNCTION_TIMEOUT=30"
70-
-e "AWS_LAMBDA_FUNCTION_MEMORY_SIZE=128"
71-
-e "AWS_REGION=us-east-1"
72-
-e "_HANDLER=handler.handler"
73-
--entrypoint /var/rapid/init
74-
)
75-
76-
CID=$(docker run "${docker_opts[@]}" public.ecr.aws/lambda/python:3.12)
58+
CID=$(make -s --no-print-directory -C "$SCRIPT_DIR" start-rie-detached)
7759
echo "$CID" > "$CID_FILE"
7860
echo ">>> RIE container: $CID"
7961

0 commit comments

Comments
 (0)