Skip to content

Commit 7bccd31

Browse files
author
andrew
committed
less annoying output
2 parents c3344ef + 1815a42 commit 7bccd31

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

aliases

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ alias deployments-group='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma deployments-gro
9797
alias distributions='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma distributions'
9898
alias ecr-repositories='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecr-repositories'
9999
alias ecr-repository-images='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecr-repository-images'
100-
alias ecs-clusters2='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecs-clusters2'
100+
alias ecs-clusters='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecs-clusters'
101101
alias ecs-scaling-actions='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecs-scaling-actions'
102102
alias ecs-scaling-activities='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecs-scaling-activities'
103-
alias ecs-services2='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecs-services2'
103+
alias ecs-services='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecs-services'
104104
alias ecs-tasks='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma ecs-tasks'
105105
alias elasticache-replication-groups='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma elasticache-replication-groups'
106106
alias elasticaches='${BMA_HOME:-$HOME/.bash-my-aws}/bin/bma elasticaches'

functions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ deployments-group
9797
distributions
9898
ecr-repositories
9999
ecr-repository-images
100-
ecs-clusters2
100+
ecs-clusters
101101
ecs-scaling-actions
102102
ecs-scaling-activities
103-
ecs-services2
103+
ecs-services
104104
ecs-tasks
105105
elasticache-replication-groups
106106
elasticaches

lib/stack-functions

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

220237
stack-update() {

0 commit comments

Comments
 (0)