-
Notifications
You must be signed in to change notification settings - Fork 19
/
deploy.sh
executable file
·60 lines (49 loc) · 1.55 KB
/
deploy.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash -ex
# example command: ./deploy.sh dev sagemaker-us-east-1234
TARGET_ENV=$1
PACKAGE_BUCKET=${2:-sagemaker-us-east-1-671846148176}
get_region() {
REGION=$(aws configure get region)
if [ "$REGION" == "None" ]; then
echo "REGION is unset in your AWS configuration";
exit 1;
else
echo "REGION is set to ${REGION}";
fi
}
get_config() {
if [ ! -f config/deploy-${REGION}-${TARGET_ENV}.ini ]; then
echo "Config file does not exist for ${REGION}, ${TARGET_ENV}";
exit 1;
else
echo "Config file exists";
. config/deploy-${REGION}-${TARGET_ENV}.ini
STACK_NAME="$PipelineName-$TargetEnv"
echo $STACK_NAME
fi
}
package () {
# Package the aws cloud formation templates
aws cloudformation package \
--region ${REGION} \
--template-file templates/master.yaml \
--s3-bucket ${PACKAGE_BUCKET} \
--s3-prefix clouformation-packaged \
--output-template-file templates/master_packaged.yaml
# Validate the AWS cloud formation template
aws cloudformation validate-template \
--template-body file://./templates/master_packaged.yaml
}
deploy () {
aws cloudformation deploy \
--region=${REGION} \
--stack-name ${STACK_NAME} \
--template-file ./templates/master_packaged.yaml \
--parameter-overrides $(cat config/deploy-${REGION}-${TARGET_ENV}.ini) PackageBucket=${PACKAGE_BUCKET} \
--capabilities CAPABILITY_NAMED_IAM CAPABILITY_IAM CAPABILITY_AUTO_EXPAND
rm -f ./templates/master_packaged.yaml
}
get_region
get_config
package
deploy