forked from atombrenner/aws-lambda-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·21 lines (20 loc) · 785 Bytes
/
deploy.sh
File metadata and controls
executable file
·21 lines (20 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function deploy {
# Generate a version number based on a date timestamp so that it's unique
TIMESTAMP=$(date +%Y%m%d%H%M%S)
# Run the npm commands to transpile the TypeScript to JavaScript
rm -rf dist &&
pnpm i &&
pnpm build &&
# Create a dist folder and copy only the js files to dist.
# AWS Lambda does not have a use for a package.json or typescript files on runtime.
cd dist &&
find . -name "*.zip" -type f -delete &&
# Zip everything in the dist folder and
zip -r lambda_function_${TIMESTAMP}.zip . &&
cp lambda_function_${TIMESTAMP}.zip ../terraform/aws/zips &&
cd .. &&
cd terraform/aws &&
terraform plan -input=false -var lambdasVersion="${TIMESTAMP}" -out=./tfplan &&
terraform apply -input=false ./tfplan
}
deploy