@@ -99,7 +99,7 @@ stack-create() {
99
99
# type: action
100
100
# create a new stack
101
101
local inputs=$( __bma_read_inputs $@ )
102
- local stack=$( _stack_name_arg $inputs )
102
+ local stack=$( _stack_name_arg $( __bma_read_resources ${ inputs} ) )
103
103
[[ -z ${stack} ]] && __bma_usage " stack [template-file] [parameters-file]" && return 1
104
104
105
105
local template=$( _stack_template_arg $inputs )
@@ -120,7 +120,7 @@ stack-update() {
120
120
# type: action
121
121
# update an existing stack
122
122
local inputs=$( __bma_read_inputs $@ )
123
- local stack=$( _stack_name_arg $inputs )
123
+ local stack=$( _stack_name_arg $( __bma_read_resources ${ inputs} ) )
124
124
[[ -z ${stack} ]] && __bma_usage " stack [template-file] [parameters-file]" && return 1
125
125
126
126
local template=$( _stack_template_arg $inputs )
@@ -141,8 +141,7 @@ stack-delete() {
141
141
# type: action
142
142
# delete an existing stack
143
143
local inputs=$( __bma_read_inputs $@ )
144
- local first_resource=$( __bma_read_resources ${inputs} | head -1)
145
- local stack=$( _stack_name_arg $first_resource )
144
+ local stack=$( _stack_name_arg $( __bma_read_resources ${inputs} ) )
146
145
[[ -z " ${stack} " ]] && __bma_usage " stack" && return 1
147
146
148
147
if aws cloudformation delete-stack --stack-name $stack ; then
@@ -155,8 +154,7 @@ stack-failure() {
155
154
# return the reason a stack failed to update/create/delete
156
155
# FIXME: only grab the latest failure
157
156
local inputs=$( __bma_read_inputs $@ )
158
- local first_resource=$( __bma_read_resources ${inputs} | head -1)
159
- local stack=$( _stack_name_arg $first_resource )
157
+ local stack=$( _stack_name_arg $( __bma_read_resources ${inputs} ) )
160
158
[[ -z " ${stack} " ]] && __bma_usage " stack" && return 1
161
159
162
160
local query='
@@ -178,8 +176,7 @@ stack-events() {
178
176
# type: detail
179
177
# return the events a stack has experienced
180
178
local inputs=$( __bma_read_inputs $@ )
181
- local first_resource=$( __bma_read_resources ${inputs} | head -1)
182
- local stack=$( _stack_name_arg $first_resource )
179
+ local stack=$( _stack_name_arg $( __bma_read_resources ${inputs} ) )
183
180
[[ -z ${stack} ]] && __bma_usage " stack" && return 1
184
181
185
182
local query='
@@ -206,7 +203,7 @@ stack-resources() {
206
203
# type: detail
207
204
# return the resources managed by a stack
208
205
local inputs=$( __bma_read_inputs $@ )
209
- local stack=$( __bma_read_resources ${inputs} | head -1 )
206
+ local stack=$( _stack_name_arg $( __bma_read_resources ${inputs} ) )
210
207
[[ -z ${stack} ]] && __bma_usage " stack" && return 1
211
208
212
209
local query=' StackResources[].[ PhysicalResourceId, ResourceType ]'
@@ -242,7 +239,7 @@ stack-parameters() {
242
239
# type: detail
243
240
# return the parameters applied to a stack
244
241
local inputs=$( __bma_read_inputs $@ )
245
- local stack=$( __bma_read_resources ${inputs} | head -1 )
242
+ local stack=$( _stack_name_arg $( __bma_read_resources ${inputs} ) )
246
243
[[ -z ${stack} ]] && __bma_usage " stack" && return 1
247
244
248
245
local query=' sort_by(Stacks[].Parameters[], &ParameterKey)'
@@ -274,8 +271,10 @@ stack-status() {
274
271
stack-tail () {
275
272
# type: detail
276
273
# follow the events occuring for a stack
277
- local stack=$( __bma_read_inputs $@ | cut -f1)
274
+ local inputs=$( __bma_read_inputs $@ )
275
+ local stack=$( _stack_name_arg $( __bma_read_resources ${inputs} ) )
278
276
[[ -z ${stack} ]] && __bma_usage " stack" && return 1
277
+
279
278
local current
280
279
local final_line
281
280
local output
@@ -316,7 +315,7 @@ stack-outputs() {
316
315
# type: detail
317
316
# return the outputs of a stack
318
317
local inputs=$( __bma_read_inputs $@ )
319
- local stack=$( __bma_read_resources ${inputs} | awk ' {print $1} ' )
318
+ local stack=$( _stack_name_arg $( __bma_read_resources ${inputs} ) )
320
319
[[ -z ${stack} ]] && __bma_usage " stack" && return 1
321
320
322
321
local query='
0 commit comments