@@ -140,7 +140,7 @@ stack-create() {
140140 # to take advantage of shorter commands*
141141 #
142142 # USAGE: stack-create stack [template-file] [parameters-file] \
143- # [--capabilities=OPTIONAL_VALUE ] [--role-arn=OPTIONAL_VALUE]
143+ # [CAPABILITY_1 CAPABILITY_2 ] [--role-arn=OPTIONAL_VALUE]
144144 #
145145 # $ stack-create params/asg-params-prod.json
146146 # Resolved arguments: asg-prod ./asg.yml params/asg-params-prod.json
@@ -177,29 +177,44 @@ stack-create() {
177177 local inputs_array=($@ )
178178 local IFS=' =' # override default field separator in the scope of this function only
179179 local regex_role_arn=" ^\-\-role\-arn=.*"
180- local regex_capabilities=" ^\-\-capabilities=.*"
180+ local list_capabilities=(" CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND" )
181+
181182 for index in " ${inputs_array[@]} " ; do
182183 if [[ " $index " =~ $regex_role_arn ]] ; then
183184 read arn_opt arn_arg <<< " $index" # ignore anything after option + arg
184185 arn=" --role-arn $arn_arg "
185- elif [[ " $index " =~ $regex_capabilities ]] ; then
186- read caps_opt caps_arg <<< " $index" # ignore anything after option + arg
187- capabilities=" --capabilities $caps_arg "
186+ fi
187+ # search for anything in the capabilities list, with or without "--capabilities"
188+ test_capability=${index##* }
189+ if [[ " $list_capabilities " =~ " $test_capability " ]] ; then
190+ capabilities=" ${capabilities} ${test_capability} "
188191 fi
189192 done
193+ if [ ! -z " ${capabilities} " ] ; then
194+ capabilities=" --capabilities ${capabilities} "
195+ fi
196+ # # TODO: add capabilities shell completion
197+
190198 unset IFS # to prevent it from breaking things later
191199
192- if aws cloudformation create-stack \
200+ if output=$(
201+ aws cloudformation create-stack \
193202 --stack-name $stack \
194203 --template-body file://$template \
195204 $parameters \
196205 $capabilities \
197206 $arn \
198207 --disable-rollback \
199- --output text; then
208+ --output text \
209+ 2>&1
210+ ) ; then
200211 stack-tail $stack
201212 else
213+ <<< <<< < HEAD
202214 echo " $output "
215+ =======
216+ echo " stack creation failed because $output "
217+ >>>>>>> features/stack-capabilities
203218 if [[ $output == * " InsufficientCapabilitiesException" * ]] ; then
204219 for capability in ${list_capabilities} ; do
205220 if [[ $output == * " $capability " * ]] ; then
@@ -215,6 +230,8 @@ stack-create() {
215230 fi
216231 fi
217232 fi
233+
234+
218235}
219236
220237stack-update () {
0 commit comments