-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow Lambda provider to use any version of Linux (#584)
Previously we required Amazon Linux 2023 (and the error message erroneously said Amazon Linux 2). With this change, we will still be using Amazon Linux 2023 by default, but Ubuntu and Amazon Linux 2 will also be supported. Note that this changes the default base image from `public.ecr.aws/lambda/nodejs:20-x86_64` to `public.ecr.aws/amazonlinux/amazonlinux:2023`. The new image contains all the packages in the old one plus a few more Python packages. The new image is a bit smaller so might load faster. The only difference should be nodejs 20 in `/var/lang` which also includes the Lambda runtime. Resolves #510 Resolves #423 BREAKING CHANGE: Node.js is no longer included by default with Lambda runner images
- Loading branch information
Showing
10 changed files
with
96 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
while true | ||
do | ||
# get data from lambda | ||
HEADERS="$(mktemp)" | ||
EVENT_DATA=$(curl -sS -LD "$HEADERS" "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") | ||
REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) | ||
|
||
# execute runner and respond | ||
if bash /runner.sh "$EVENT_DATA"; then | ||
curl "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "" | ||
else | ||
curl "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/error" -d "{\"errorMessage\": \"Runner failed with exit code $?\", \"errorType\": \"Error\", \"stackTrace\": []}" | ||
fi | ||
|
||
# cleanup | ||
find /tmp -mindepth 1 -maxdepth 1 -exec rm -rf '{}' \; | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# workaround for "Cannot get required symbol EVP_rc2_cbc from libssl" | ||
# lambda docker image for node.js comes with stripped down libssl.so pushed in LD_LIBRARY_PATH | ||
if [ -f /var/lang/lib/libssl.so ]; then | ||
export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH | ||
fi | ||
|
||
# extract parameters | ||
OWNER=$(echo "$1" | jq -r .owner) | ||
REPO=$(echo "$1" | jq -r .repo) | ||
GITHUB_DOMAIN=$(echo "$1" | jq -r .githubDomain) | ||
RUNNER_TOKEN=$(echo "$1" | jq -r .token) | ||
RUNNER_NAME=$(echo "$1" | jq -r .runnerName) | ||
RUNNER_LABEL=$(echo "$1" | jq -r .label) | ||
REGISTRATION_URL=$(echo "$1" | jq -r .registrationUrl) | ||
|
||
# copy runner code (it needs a writable directory) | ||
cp -r /home/runner /tmp/ | ||
cd /tmp/runner | ||
|
||
# setup home directory | ||
mkdir /tmp/home | ||
export HOME=/tmp/home | ||
|
||
# start runner | ||
if [ "${RUNNER_VERSION}" = "latest" ]; then RUNNER_FLAGS=""; else RUNNER_FLAGS="--disableupdate"; fi | ||
./config.sh --unattended --url "${REGISTRATION_URL}" --token "${RUNNER_TOKEN}" --ephemeral --work _work --labels "${RUNNER_LABEL},cdkghr:started:`date +%s`" --name "${RUNNER_NAME}" ${RUNNER_FLAGS} | ||
echo Config done | ||
./run.sh | ||
echo Run done | ||
|
||
# print status for metrics | ||
STATUS=$(grep -Phors "finish job request for job [0-9a-f\-]+ with result: \K.*" _diag/ | tail -n1) | ||
[ -n "$STATUS" ] && echo CDKGHA JOB DONE "$RUNNER_LABEL" "$STATUS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.