-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdeploy
executable file
·36 lines (30 loc) · 935 Bytes
/
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
#!/bin/bash -e
if [ -z "$1" ]; then
echo "Usage:"
echo " deploy my.bucket.name"
echo "The bucket will be used to store the Lambda code when deploying."
echo "It will be created if needed"
exit 1
else
s3Bucket=$1
fi
output_template_file=$(mktemp)
# build Lambda code for Linux
docker build -t "cloudformation-lambda-cookies" .
docker run "cloudformation-lambda-cookies" > dist/lambda.zip
# create the target S3 bucket if needed
aws s3 ls ${s3Bucket} > /dev/null
if [ $? -ne 0 ]; then
aws s3 mb ${s3Bucket}
fi
# create and upload the CloudFormation package
aws cloudformation package \
--template-file app.yml \
--output-template-file ${output_template_file} \
--s3-bucket ${s3Bucket}
# deploy it
aws cloudformation deploy \
--template-file ${output_template_file} \
--stack-name LambdaCloudformationCookies \
--capabilities CAPABILITY_IAM \
--parameter-overrides file://dist/config.json