-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupdate-lambda.sh
executable file
·34 lines (26 loc) · 1.04 KB
/
update-lambda.sh
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/sh
# This script will build the provided project, copy the zip file to S3 and then call
# `update-function-code` with the AWS Cli to update the lambda.
# Usage: ./update-lambda.sh [project name]
# eg. ./update-lambda.sh discount-api
# Exit if any of these commands fail
set -e
if [ $# -lt 1 ]; then
echo "please provide the project name as an argument, eg. ./update-lambda.sh discount-api"
exit 2
fi
PROJECT_NAME="$1"
echo "Updating lambda $PROJECT_NAME"
pnpm --filter $PROJECT_NAME package
s3Bucket=`aws ssm get-parameter --name /account/services/artifact.bucket --query "Parameter.Value" --output text --profile membership --region eu-west-1`
s3Path="support/CODE/$PROJECT_NAME/$PROJECT_NAME.zip"
zipFile="./handlers/$PROJECT_NAME/target/$PROJECT_NAME.zip"
aws s3 cp $zipFile s3://$s3Bucket/$s3Path --profile membership --region eu-west-1
aws lambda update-function-code \
--function-name $PROJECT_NAME-CODE \
--s3-bucket $s3Bucket \
--s3-key $s3Path \
--profile membership \
--region eu-west-1 \
> /dev/null
echo "Update complete"