-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchangeset-create.sh
executable file
·73 lines (61 loc) · 1.95 KB
/
changeset-create.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
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
#
# Simple shell script to run a CloudFormation template with a set of parameters and tags
#
Usage () {
cat <<EOF
$0 profile directory stackname changesetname [other arguments]
This will create a change set named "changename" for the cloudformation stack named "stackname" which uses
the main.yaml CloudFormation template in the directory "directory" unless a "name.yaml" exists in that
directory. In addition it will look in the "directory/settings" subdirectory for parameters and tags of the form:
directory/settings/name-parameters.json
directory/settings/name-tags.json
EOF
exit
}
debug=
if [ "x$1" = "x-d" ]; then
debug=echo
shift
fi
if [ "$#" -lt 4 ]; then
Usage
fi
profile="$1"
shift
directory="$1"
shift
name="$1"
shift
changename="$1"
shift
ARGS="$@"
# figure out the stack to run
if [ -f "${directory}/${name}.yaml" ]; then
ARGS="$ARGS --template-body file://${directory}/${name}.yaml "
elif [ -f "${directory}/main.yaml" ]; then
ARGS="$ARGS --template-body file://${directory}/main.yaml "
else
echo "No main template found in that directory"
Usage
fi
# figure out the parameter file to use
if [ -f"${directory}/settings/${name}-parameters.json" ]; then
ARGS="$ARGS --parameters file://${directory}/settings/${name}-parameters.json "
elif [ -f "${directory}/settings/main-parameters.json" ]; then
ARGS="$ARGS --parameters file://${directory}/settings/main-parameters.json "
else
echo "No parameters were found in the settings subdirectory"
Usage
fi
# figure out the tags file to use
if [ -f "${directory}/settings/${name}-tags.json" ]; then
ARGS="$ARGS --tags file://${directory}/settings/${name}-tags.json "
elif [ -f "${directory}/settings/main-parameters.json" ]; then
ARGS="$ARGS --tags file://${directory}/settings/main-tags.json "
else
echo "# Skipping tags since none were found"
fi
$debug exec aws --profile "$profile" cloudformation create-change-set \
--stack-name "$name" --change-set-name "$changename" $ARGS
exit