This repository has been archived by the owner on Sep 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdeploy
41 lines (39 loc) · 1.8 KB
/
deploy
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
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
rm -f LambdaFunction.zip \
&& rm -rf LambdaFunction \
&& mkdir LambdaFunction \
&& cp -r ./src/* ./LambdaFunction \
&& pip install -r ./requirements.txt -t ./LambdaFunction --no-cache-dir \
&& find ./LambdaFunction -name "*.pyc" -type f -delete \
&& cd ./LambdaFunction \
&& zip -r ../LambdaFunction.zip * \
&& cd .. \
&& if [ -z "$1" ]; then
echo "No deployment S3 bucket specified."
else
aws s3 cp LambdaFunction.zip s3://$1 \
&& aws s3 --recursive cp ./resources/ s3://$1 \
&& if [ -z "$2" ]; then
echo "No cloudformation stack name specified."
else
if [ -z "$3" ]; then
aws cloudformation create-stack --stack-name $2 \
--template-url https://s3.amazonaws.com/$1/CloudFormationTemplate.yml \
--parameters ParameterKey=BlueprintBucket,ParameterValue=$1 \
ParameterKey=BlueprintObject,ParameterValue=DefaultBlueprint.json \
ParameterKey=LambdaPkgBucket,ParameterValue=$1 \
ParameterKey=LambdaPkgObject,ParameterValue=LambdaFunction.zip\
--capabilities CAPABILITY_IAM
else
aws cloudformation create-stack --stack-name $2 \
--template-url https://s3.amazonaws.com/$1/CloudFormationTemplate.yml \
--parameters ParameterKey=BlueprintBucket,ParameterValue=$1 \
ParameterKey=BlueprintObject,ParameterValue=$3 \
ParameterKey=LambdaPkgBucket,ParameterValue=$1 \
ParameterKey=LambdaPkgObject,ParameterValue=LambdaFunction.zip\
--capabilities CAPABILITY_IAM
fi
fi
fi
rm -rf LambdaFunction