-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage.sh
executable file
·42 lines (31 loc) · 1.25 KB
/
stage.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
# Staging script for copying deployment resources to an S3 bucket.
set -e
BUCKET=$1
#Path with trailing /
S3PATH=$2
# remove this line if you want to keep the objects private in your S3 bucket
#export S3PUBLIC=" --acl public-read"
if [ ! -d "local" ]; then
mkdir local
fi
touch local/stage.log
if [ "$BUCKET" == "" ]; then
echo "Usage: $0 BUCKET [S3PATH]"
echo " where BUCKET is the S3 bucket to upload resources to and S3PATH is optional path but if specified must have a trailing '/'"
exit 1
fi
BUCKET_LOCATION="$(aws s3api get-bucket-location --bucket ${BUCKET}|grep ":"|cut -d\" -f4)"
if [ -z "$BUCKET_LOCATION" ]; then
BUCKET_DOMAIN="s3.amazonaws.com"
else
BUCKET_DOMAIN="s3-${BUCKET_LOCATION}.amazonaws.com"
fi
# Remove Mac desktop storage files so they don't get packaged & uploaded
find . -name '.DS_Store' -type f -delete
echo " + Staging to $BUCKET in $S3PATH"
echo " + Uploading CloudFormation Templates"
aws s3 cp templates/ s3://${BUCKET}/${S3PATH}templates --recursive $S3PUBLIC
echo " For CloudFormation : https://${BUCKET_DOMAIN}/${BUCKET}/${S3PATH}templates/template.yaml"
echo " + Done s3://${BUCKET}/${S3PATH} "
echo " For CloudFormation : https://${BUCKET_DOMAIN}/${BUCKET}/${S3PATH}templates/template.yaml"