Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Draft
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
7 changes: 7 additions & 0 deletions 7 .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 64 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"}
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 17 scripts/aws/aws-deploy-local-layer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ set -euo pipefail

# 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 \
--license-info "MIT" \
--no-cli-pager

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

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.