-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish-layer.sh
More file actions
executable file
·50 lines (39 loc) · 1.06 KB
/
Copy pathpublish-layer.sh
File metadata and controls
executable file
·50 lines (39 loc) · 1.06 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Prompt for input if no args
get_input() {
local prompt_text="$1"
local var_value="$2"
if [ -z "$var_value" ]; then
read -p "$prompt_text: " input
echo "$input"
else
echo "$var_value"
fi
}
REGION=$(get_input "AWS Region" "$1")
BUCKET_NAME=$(get_input "S3 Bucket" "$2")
echo "---"
echo "Building Chromium Layer..."
echo "---"
rm -rf layer-build
mkdir -p layer-build/nodejs
cd layer-build/nodejs
npm init -y > /dev/null
npm install @sparticuz/chromium@latest
cd ..
zip -r -q chromium-layer.zip nodejs
echo "Uploading to S3..."
aws s3 cp chromium-layer.zip "s3://$BUCKET_NAME/chromium-layer.zip"
echo "Publishing Layer..."
LAYER_VERSION_ARN=$(aws lambda publish-layer-version \
--layer-name "chromium-layer" \
--description "Chromium for Node 24" \
--content S3Bucket="$BUCKET_NAME",S3Key="chromium-layer.zip" \
--compatible-runtimes nodejs24.x \
--region "$REGION" \
--query 'LayerVersionArn' \
--output text)
cd ..
rm -rf layer-build
echo "---"
echo "Layer Published: $LAYER_VERSION_ARN"