Skip to content

Commit c1ae7bf

Browse files
committed
Add type and description to each instance function
1 parent 8e32907 commit c1ae7bf

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

lib/instance-functions

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ instances() {
5151
}
5252

5353
instance-asg() {
54+
# type: query
55+
# returns the autoscaling group an instances is a member of
5456
local inputs="$(__bma_read_inputs $@)"
5557
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
5658
local query='
@@ -65,7 +67,8 @@ instance-asg() {
6567
}
6668

6769
instance-console() {
68-
# detail
70+
# type: detail
71+
# returns the console output of an instance
6972
local inputs=$(__bma_read_inputs $@)
7073
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
7174
for instance_id in $(__bma_read_resources ${inputs}); do
@@ -79,7 +82,8 @@ instance-console() {
7982
}
8083

8184
instance-dns() {
82-
## detail
85+
# type: detail
86+
# returns the dns name of an instance
8387
local inputs="$(__bma_read_inputs $@)"
8488
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
8589
local query='
@@ -95,7 +99,8 @@ instance-dns() {
9599
}
96100

97101
instance-iam-profile() {
98-
## detail
102+
# type: detail
103+
# returns the iam-profile of an instance
99104
local inputs="$(__bma_read_inputs $@)"
100105
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
101106
local query='
@@ -110,7 +115,8 @@ instance-iam-profile() {
110115
}
111116

112117
instance-ip() {
113-
## detail
118+
# type: detail
119+
# returns the ip address of an instance
114120
local inputs="$(__bma_read_inputs $@)"
115121
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
116122
local query='
@@ -126,6 +132,8 @@ instance-ip() {
126132
}
127133

128134
instance-ssh() {
135+
# type: action
136+
# connects to an instance via SSH
129137
# XXX Does not work with input from STDIN
130138

131139
# TODO: this may be cleaner
@@ -159,6 +167,8 @@ instance-ssh() {
159167
}
160168

161169
instance-ssh-details() {
170+
# type: detail
171+
# returns the details needed to SSH into an instance
162172
local inputs="$(__bma_read_inputs $@)"
163173
[[ -z "${inputs}" ]] && __bma_usage "instance_id" && return 1
164174

@@ -175,6 +185,8 @@ instance-ssh-details() {
175185
}
176186

177187
instance-stack() {
188+
# type: detail
189+
# returns the stack an instances is a member of
178190
local inputs="$(__bma_read_inputs $@)"
179191
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
180192
local query='
@@ -189,13 +201,16 @@ instance-stack() {
189201
}
190202

191203
instance-start() {
204+
# type: action
205+
# starts a stopped instance
192206
local inputs="$(__bma_read_inputs $@)"
193207
[[ -z "$inputs" ]] && __bma_usage "instance-id" && return 1
194208
aws ec2 start-instances --instance-id $inputs
195209
}
196210

197211
instance-state() {
198-
## detail
212+
# type: detail
213+
# returns the state of an instance
199214
local inputs="$(__bma_read_inputs $@)"
200215
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
201216
local query='
@@ -210,6 +225,8 @@ instance-state() {
210225
}
211226

212227
instance-stop() {
228+
# type: action
229+
# stops a running instance
213230
local inputs="$(__bma_read_inputs $@)"
214231
[[ -z "$inputs" ]] && __bma_usage "instance-id" && return 1
215232
aws ec2 stop-instances --instance-id $inputs
@@ -221,6 +238,8 @@ instance-stop() {
221238
# instances_without_tag() # instance_tags | grep -v expiry=
222239
#
223240
instance-tags() {
241+
# type: detail
242+
# returns the tags applied instances
224243
local inputs="$(__bma_read_inputs $@)"
225244
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
226245
local query='
@@ -233,11 +252,15 @@ instance-tags() {
233252
}
234253

235254
instance-terminate() {
255+
# type: action
256+
# terminates an instance
236257
aws ec2 modify-instance-attribute --attribute disableApiTermination --value false --instance-id $1
237258
aws ec2 terminate-instances --instance-id $1
238259
}
239260

240261
instance-type() {
262+
# type: detail
263+
# returns the type of an instance
241264
local inputs="$(__bma_read_inputs $@)"
242265
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
243266
local query='
@@ -252,7 +275,8 @@ instance-type() {
252275
}
253276

254277
instance-userdata() {
255-
# detail
278+
# type: detail
279+
# returns the userdata of an instance
256280
local inputs=$(__bma_read_inputs $@)
257281
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
258282
for instance_id in $(__bma_read_resources ${inputs}); do
@@ -266,6 +290,8 @@ instance-userdata() {
266290
}
267291

268292
instance-volumes() {
293+
# type: detail
294+
# returns the volumes of an instance
269295
local inputs=$(__bma_read_inputs $@)
270296
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
271297
local query='
@@ -280,6 +306,8 @@ instance-volumes() {
280306
}
281307

282308
instance-vpc() {
309+
# type: detail
310+
# returns the vpc of an instance
283311
local inputs=$(__bma_read_inputs $@)
284312
[[ -z "$inputs" ]] && __bma_usage "instance-id [instance-id]" && return 1
285313
local query='

0 commit comments

Comments
 (0)