Skip to content

Commit fdc2eac

Browse files
committed
[python_lambda] simplify installation of datadog_lambda
1 parent c8a6aab commit fdc2eac

5 files changed

Lines changed: 30 additions & 105 deletions

File tree

utils/build/build.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ build() {
217217

218218
DOCKERFILE=utils/build/docker/${TEST_LIBRARY}/${WEBLOG_VARIANT}.Dockerfile
219219

220-
if [[ $TEST_LIBRARY == python_lambda ]]; then
221-
./utils/build/docker/python_lambda/build_lambda_layer.sh
222-
fi
223-
224220
docker buildx build \
225221
--build-arg BUILDKIT_INLINE_CACHE=1 \
226222
--load \

utils/build/docker/python_lambda/apigw-rest.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
FROM public.ecr.aws/lambda/python:3.13
22

3-
RUN dnf install -y unzip
3+
RUN dnf install -y unzip findutils
44

55
# Add the Datadog Extension
66
RUN mkdir -p /opt/extensions
77
COPY --from=public.ecr.aws/datadog/lambda-extension:latest /opt/. /opt/
88

9-
COPY binaries/* /binaries/
10-
RUN unzip /binaries/*.zip -d /opt
9+
COPY utils/build/docker/python_lambda/install_datadog_lambda.sh binaries* /binaries/
10+
RUN /binaries/install_datadog_lambda.sh
1111

1212
# Setup the aws_lambda handler
1313
COPY utils/build/docker/python_lambda/function/. ${LAMBDA_TASK_ROOT}

utils/build/docker/python_lambda/build_lambda_layer.sh

Lines changed: 0 additions & 96 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
cd /binaries
6+
7+
if [ "$(find . -maxdepth 1 -name "*.zip" | wc -l)" = "1" ]; then
8+
path=$(readlink -f "$(find . -maxdepth 1 -name "*.zip")")
9+
echo "Install datadog_lambda from ${path}"
10+
unzip "${path}" -d /opt
11+
else
12+
echo "Fetching from latest GitHub release"
13+
curl -fsSLO https://github.com/DataDog/datadog-lambda-python/releases/latest/download/datadog_lambda_py-amd64-3.13.zip
14+
15+
if [ ! -f datadog_lambda_py-amd64-3.13.zip ]; then
16+
echo "Failed to download datadog_lambda_py-amd64-3.13.zip"
17+
exit 1
18+
fi
19+
fi

utils/scripts/load-binary.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,16 @@ elif [ "$TARGET" = "waf_rule_set" ]; then
297297
-H "Accept: application/vnd.github.v3.raw" \
298298
https://api.github.com/repos/DataDog/appsec-event-rules/contents/build/recommended.json
299299
elif [ "$TARGET" = "python_lambda" ]; then
300-
assert_version_is_dev
301300
assert_target_branch_is_not_set
302301

303-
get_github_action_artifact "DataDog/datadog-lambda-python" "build_layer.yml" "main" "datadog-lambda-python-3.13-amd64" "datadog_lambda_py-amd64-3.13.zip"
302+
if [ $VERSION = 'dev' ]; then
303+
get_github_action_artifact "DataDog/datadog-lambda-python" "build_layer.yml" "main" "datadog-lambda-python-3.13-amd64" "datadog_lambda_py-amd64-3.13.zip"
304+
elif [ $VERSION = 'prod' ]; then
305+
get_github_release_asset "DataDog/datadog-lambda-python" "datadog_lambda_py-amd64-3.13.zip"
306+
else
307+
echo "Don't know how to load version $VERSION for $TARGET"
308+
exit 1
309+
fi
304310

305311
else
306312
echo "Unknown target: $1"

0 commit comments

Comments
 (0)