This repository was archived by the owner on Mar 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·53 lines (44 loc) · 1.37 KB
/
build.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.37 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
51
52
53
#!/bin/bash
# Build Lambda deployment packages
# Creates: lambda_code.zip (handler) and lambda_layer.zip (dependencies)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Building Lambda packages..."
# Clean previous builds
rm -rf build/ layer/
rm -f lambda_code.zip lambda_layer.zip lambda_package.zip
# === Build code package (just the handler) ===
echo "Creating code package..."
mkdir -p build/
cp src/redshift_to_postgres_sync.py build/
cd build/
zip -r ../lambda_code.zip . -q
cd ..
rm -rf build/
# === Build layer package (dependencies) ===
echo "Creating layer package..."
mkdir -p layer/python
# Use pip with platform targeting for Lambda (Amazon Linux 2023 / x86_64)
pip3 install \
--platform manylinux2014_x86_64 \
--implementation cp \
--python-version 3.12 \
--only-binary=:all: \
--target layer/python \
psycopg2-binary redshift-connector boto3 \
--quiet 2>/dev/null || {
echo "Platform-specific install failed, trying regular install..."
pip3 install psycopg2-binary redshift-connector boto3 -t layer/python --quiet
}
cd layer/
zip -r ../lambda_layer.zip . -q
cd ..
rm -rf layer/
echo ""
echo "✓ Build complete!"
echo " lambda_code.zip: $(du -h lambda_code.zip | cut -f1) (handler only)"
echo " lambda_layer.zip: $(du -h lambda_layer.zip | cut -f1) (dependencies)"
echo ""
echo "Next steps:"
echo " terraform apply"