-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-inference-function.sh
42 lines (38 loc) · 1.25 KB
/
deploy-inference-function.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
35
36
37
38
39
40
41
42
#!/bin/bash
# This script installs the inference function for use within DeepLens.
# Usage: ./deploy-inference-function.sh --bucket <bucketname> --stack-name <stackname>
HELP="You must include --bucket (S3 bucket name) and --stack-name (CloudFormation stack name)"
for i in "$@"
do
case $i in
--bucket|-b|--bucket-name)
BUCKETNAME="${2}"
;;
--stack-name|-s|--stack)
STACKNAME="${1}"
;;
-h|--help)
echo ${HELP}
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
shift
done
if [ -z "$BUCKETNAME" -o -z "$STACKNAME" ]; then
echo ${HELP}
else
# Package the Lambda function
if sam build -t inference-template.yaml; then
# Transform the SAM template to an AWS CloudFormation template
if sam package --s3-bucket "${BUCKETNAME}" --output-template-file packaged-template.yaml; then
# Deploy the CloudFormation template
sam deploy --template-file ./packaged-template.yaml --stack-name "${STACKNAME}" --capabilities CAPABILITY_NAMED_IAM;
# Remove the intermediate template
rm ./packaged-template.yaml;
fi
fi
fi