Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .craft.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
minVersion: 2.21.1
minVersion: 2.28.0
preReleaseCommand: bash scripts/bump-version.sh
targets:
- name: pypi
Expand All @@ -12,6 +12,8 @@ targets:
# This regex that matches the version is taken from craft:
# https://github.com/getsentry/craft/blob/8d77c38ddbe4be59f98f61b6e42952ca087d3acd/src/utils/version.ts#L11
includeNames: /^sentry-python-serverless-\bv?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-?([\da-z-]+(?:\.[\da-z-]+)*))?(?:\+([\da-z-]+(?:\.[\da-z-]+)*))?\b.zip$/
# If we ever want per-major layer names like JavaScript's
# SentryNodeServerlessSDKv10:84, craft supports {{{major}}} templating.
layerName: SentryPythonServerlessSDK
compatibleRuntimes:
- name: python
Expand All @@ -28,6 +30,11 @@ targets:
- python3.11
- python3.12
- python3.13
- python3.14
compatibleArchitectures:
# Both x86_64 and arm64 are supported by default; explicitly listing for better visibility
Comment thread
sentry-warden[bot] marked this conversation as resolved.
- x86_64
- arm64
license: MIT
- name: sentry-pypi
internalPypiRepo: getsentry/pypi
Expand Down
64 changes: 64 additions & 0 deletions scripts/aws/aws-configure-layer-on-lambda-function.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
#
# Attach the layer first with: ./scripts/aws/aws-attach-layer-to-lambda-function.sh
#
# Replaces handler, SENTRY_DSN, SENTRY_INITIAL_HANDLER and SENTRY_TRACES_SAMPLE_RATE.

# Usage: ./scripts/aws/aws-configure-layer-on-lambda-function.sh <lambda-function-name> <dsn> <region (optional)>

set -euo pipefail

if [ $# -lt 2 ] || [ $# -gt 3 ]; then
SCRIPT_NAME=$(basename "$0")
echo "ERROR: Missing arguments."
echo "Usage: $SCRIPT_NAME <lambda-function-name> <dsn> <region (optional)>"
exit 1
fi

FUNCTION_NAME=$1
DSN=$2
SENTRY_HANDLER="sentry_sdk.integrations.init_serverless_sdk.sentry_lambda_handler"
REGION=${3:-"eu-north-1"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong default AWS region

Medium Severity

The new configure script defaults REGION to eu-north-1, but aws-deploy-local-layer.sh, aws-delete-lambda-layer-versions.sh, and CONTRIBUTING.md all use eu-central-1. Running the documented deploy → attach → configure flow without an explicit region targets the wrong region, so configuration fails or updates a different function than the one that received the local layer.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5c8c9a4. Configure here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think this script is just for testing, that's fine here

TRACES_SAMPLE_RATE="1.0"

echo "Fetching current configuration for function '$FUNCTION_NAME'..."
CONFIG=$(aws lambda get-function-configuration \
--function-name "$FUNCTION_NAME" \
--region "$REGION" \
--no-cli-pager)
CURRENT_HANDLER=$(echo "$CONFIG" | jq -r '.Handler')

if [ "$CURRENT_HANDLER" = "$SENTRY_HANDLER" ]; then
INITIAL_HANDLER=$(echo "$CONFIG" | jq -r '.Environment.Variables.SENTRY_INITIAL_HANDLER // empty')
if [ -z "$INITIAL_HANDLER" ] || [ "$INITIAL_HANDLER" = "$SENTRY_HANDLER" ]; then
echo "Handler is already set to '$SENTRY_HANDLER' but SENTRY_INITIAL_HANDLER is missing or points at it."
echo "Set SENTRY_INITIAL_HANDLER to real handler first."
exit 1
fi
echo "SENTRY_INITIAL_HANDLER already set to $INITIAL_HANDLER."
else
INITIAL_HANDLER=$CURRENT_HANDLER
fi

ENV_JSON=$(echo "$CONFIG" | jq -c \
--arg dsn "$DSN" \
--arg initial "$INITIAL_HANDLER" \
--arg traces_sample_rate "$TRACES_SAMPLE_RATE" \
'
((.Environment.Variables // {})
| del(.SENTRY_DSN, .SENTRY_INITIAL_HANDLER, .SENTRY_TRACES_SAMPLE_RATE))
+ {
SENTRY_DSN: $dsn,
SENTRY_INITIAL_HANDLER: $initial,
SENTRY_TRACES_SAMPLE_RATE: $traces_sample_rate
}
| {Variables: .}
')

echo "Updating function configuration..."
aws lambda update-function-configuration \
--function-name "$FUNCTION_NAME" \
--region "$REGION" \
--handler "$SENTRY_HANDLER" \
--environment "$ENV_JSON" \
--no-cli-pager
17 changes: 10 additions & 7 deletions scripts/aws/aws-deploy-local-layer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@

# Creating Lambda layer
echo "Creating Lambda layer in ./dist ..."
make aws-lambda-layer
uv build
uv run --group aws --with-editable . python scripts/build_aws_lambda_layer.py
echo "Done creating Lambda layer in ./dist"

# Deploying zipped Lambda layer to AWS
ZIP=$(ls dist | grep serverless | head -n 1)
echo "Deploying zipped Lambda layer $ZIP to AWS..."

aws lambda publish-layer-version \
--layer-name "SentryPythonServerlessSDK-local-dev" \
--region "eu-central-1" \
--zip-file "fileb://dist/$ZIP" \
--description "Local test build of SentryPythonServerlessSDK (can be deleted)" \
--compatible-runtimes python3.7 python3.8 python3.9 python3.10 python3.11 \
--no-cli-pager
--layer-name "SentryPythonServerlessSDK-local-dev" \
--region "eu-central-1" \
--zip-file "fileb://dist/$ZIP" \
--description "Local test build of SentryPythonServerlessSDK (can be deleted)" \
--compatible-runtimes python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13 python3.14 \
--compatible-architectures x86_64 arm64 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this compatible architectures thing actually make a difference?
I'd hope it's implied that pure Python packages support all architectures, but maybe AWS is annoying here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supports both x86_64 and arm64 indeed since it's pure Python. Just added it for visibility, currently it looks like this:
Screenshot 2026-08-10 at 11 28 52
with this change it looks like this:
Screenshot 2026-08-10 at 11 33 34

--license-info "MIT" \
--no-cli-pager

echo "Done deploying zipped Lambda layer to AWS as 'SentryPythonServerlessSDK-local-dev'."

echo "All done. Have a nice day!"
Loading