-
Notifications
You must be signed in to change notification settings - Fork 647
feat(aws-lambda): Enable Python 3.14 support to the Lambda layer #6916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2398895
4917744
f3839ce
5c8c9a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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"} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong default AWS regionMedium Severity The new configure script defaults Reviewed by Cursor Bugbot for commit 5c8c9a4. Configure here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this compatible architectures thing actually make a difference?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| --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!" | ||




Uh oh!
There was an error while loading. Please reload this page.