-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild-sam-template.sh
More file actions
executable file
·34 lines (26 loc) · 995 Bytes
/
build-sam-template.sh
File metadata and controls
executable file
·34 lines (26 loc) · 995 Bytes
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
#!/bin/bash -e
APP_NAME=$1
if [ -z "$APP_NAME" ] || { [ "$APP_NAME" != "main" ] && [ "$APP_NAME" != "quicksight-access" ] && [ "$APP_NAME" != "core" ]; }; then
echo "App name must be provided and be one of 'main' or 'quicksight-access'"
echo "Usage (bash): build-sam-templates.sh APP_NAME"
echo "Usage (npm): npm run iac:build -- APP_NAME"
exit 1
fi
ROOT=$(pwd)
IAC_DIR="$ROOT/iac"
BASE_FILE="$IAC_DIR/$APP_NAME/base.yml"
RESOURCE_DIR="$IAC_DIR/$APP_NAME/resources"
OUTFILE="$ROOT/template.yaml"
rm -f "$OUTFILE"
# start the template with the initial section in base.yml, and begin the Resources section
cat "$BASE_FILE" > "$OUTFILE"
echo -e "\nResources:" >> "$OUTFILE"
for file in "$RESOURCE_DIR"/*; do
sed 's/^/ /' < "$file" >> "$OUTFILE"
echo >> "$OUTFILE"
done
# fill in email templates when building the quicksight-access stack
if [ "$APP_NAME" == "quicksight-access" ]; then
node "$ROOT/scripts/minify-and-add-emails.mjs"
fi
prettier "$OUTFILE" --write > /dev/null