File: aws-attach-layer-to-lambda-function.sh

package info (click to toggle)
sentry-python 2.22.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,268 kB
  • sloc: python: 58,847; sh: 126; makefile: 114; xml: 2
file content (33 lines) | stat: -rwxr-xr-x 1,002 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
#
# Attaches the layer `SentryPythonServerlessSDK-local-dev` to a given lambda function.
#

set -euo pipefail

# Check for argument
if [ $# -eq 0 ]
  then
    SCRIPT_NAME=$(basename "$0")
    echo "ERROR: No argument supplied. Please give the name of a Lambda function!"
    echo ""
    echo "Usage: $SCRIPT_NAME <lambda-function-name>"
    echo ""
    exit 1
fi

FUNCTION_NAME=$1

echo "Getting ARN of newest Sentry lambda layer..."
LAYER_ARN=$(aws lambda list-layer-versions --layer-name SentryPythonServerlessSDK-local-dev --query "LayerVersions[0].LayerVersionArn" | tr -d '"')
echo "Done getting ARN of newest Sentry lambda layer $LAYER_ARN."

echo "Attaching Lamba layer to function $FUNCTION_NAME..."
echo "Warning: This remove all other layers!"
aws lambda update-function-configuration \
    --function-name "$FUNCTION_NAME" \
    --layers "$LAYER_ARN" \
    --no-cli-pager
echo "Done attaching Lamba layer to function '$FUNCTION_NAME'."

echo "All done. Have a nice day!"