Skip to content

Commit

Permalink
Lambda layer supports AWS Lambda Python 3.13 Runtime (#293)
Browse files Browse the repository at this point in the history
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
  • Loading branch information
wangzlei authored Nov 18, 2024
1 parent c17ce69 commit ca8e0e4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/release_lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
aws lambda publish-layer-version \
--layer-name ${{ env.LAYER_NAME }} \
--content S3Bucket=${{ env.BUCKET_NAME }},S3Key=aws-opentelemetry-python-layer.zip \
--compatible-runtimes python3.10 python3.11 python3.12 \
--compatible-runtimes python3.10 python3.11 python3.12 python3.13 \
--compatible-architectures "arm64" "x86_64" \
--license-info "Apache-2.0" \
--description "AWS Distro of OpenTelemetry Lambda Layer for Python Runtime" \
Expand Down Expand Up @@ -184,16 +184,16 @@ jobs:
with:
name: layer.tf
path: layer.tf
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
mv layer.tf lambda-layer/terraform/lambda/
git add lambda-layer/terraform/lambda/layer.tf
git commit -m "Update Lambda layer ARNs for releasing" || echo "No changes to commit"
git push
# - name: Commit changes
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# mv layer.tf lambda-layer/terraform/lambda/
# git add lambda-layer/terraform/lambda/layer.tf
# git commit -m "Update Lambda layer ARNs for releasing" || echo "No changes to commit"
# git push
create-release:
runs-on: ubuntu-latest
needs: generate-release-note
Expand All @@ -205,16 +205,16 @@ jobs:
echo "COMMIT_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV
- name: Create Tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
TAG_NAME="lambda-${SHORT_SHA}"
git tag -a "$TAG_NAME" -m "Release Lambda layer based on commit $TAG_NAME"
git push origin "$TAG_NAME"
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Create Tag
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# TAG_NAME="lambda-${SHORT_SHA}"
# git tag -a "$TAG_NAME" -m "Release Lambda layer based on commit $TAG_NAME"
# git push origin "$TAG_NAME"
# echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand Down
9 changes: 8 additions & 1 deletion lambda-layer/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/sam/build-python3.12 AS python312
FROM public.ecr.aws/sam/build-python3.13 AS python313

ADD . /workspace

Expand All @@ -19,6 +19,13 @@ RUN mkdir -p /build && \
chmod 755 /build/otel-instrument && \
rm -rf /build/python/urllib3*

FROM public.ecr.aws/sam/build-python3.12 AS python312

WORKDIR /workspace

COPY --from=python313 /build /build

RUN python3 -m compileall /build/python

FROM public.ecr.aws/sam/build-python3.11 AS python311

Expand Down
2 changes: 1 addition & 1 deletion lambda-layer/terraform/lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
resource "aws_lambda_layer_version" "sdk_layer" {
layer_name = var.sdk_layer_name
filename = "${path.module}/../../src/build/aws-opentelemetry-python-layer.zip"
compatible_runtimes = ["python3.10", "python3.11", "python3.12"]
compatible_runtimes = ["python3.10", "python3.11", "python3.12", "python3.13"]
license_info = "Apache-2.0"
source_code_hash = filebase64sha256("${path.module}/../../src/build/aws-opentelemetry-python-layer.zip")
}
Expand Down
10 changes: 2 additions & 8 deletions lambda-layer/terraform/lambda/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variable "sdk_layer_name" {
type = string
description = "Name of published SDK layer"
default = "aws-opentelemetry-distro-python"
default = "AWSOpenTelemetryDistroPython"
}

variable "function_name" {
Expand All @@ -19,17 +19,11 @@ variable "architecture" {
variable "runtime" {
type = string
description = "Python runtime version used for sample Lambda Function"
default = "python3.12"
default = "python3.13"
}

variable "tracing_mode" {
type = string
description = "Lambda function tracing mode"
default = "Active"
}

variable "enable_collector_layer" {
type = bool
description = "Enables building and usage of a layer for the collector. If false, it means either the SDK layer includes the collector or it is not used."
default = false
}

0 comments on commit ca8e0e4

Please sign in to comment.