-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.yaml
318 lines (308 loc) · 12.4 KB
/
config.yaml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
---
cog_bundle_version: 4
name: ec2
version: 0.1.2
docker:
image: cogcmd/aws-ec2
tag: 0.1.2
description: Manage EC2 instances and related services
long_description: >
This bundle provides commands for viewing, inspecting, and controlling EC2
instances on AWS, as well as related resources. To communicate with the AWS
API we use the aws-sdk library written in Ruby. Permissions are used to
control which users are authorized to run each command. Listing and searching
for resources requires the ec2:read permission. Modifying the state or other
values of a resource requires the ec2:write permission. And, destroying an
instance requires the ec2:admin permission.
config:
notes: >
When creating the access key for use with the following environment
variables, make sure the IAM user that owns the key has the
AmazonEC2FullAccess policy.
env:
- var: AWS_ACCESS_KEY_ID
description: Requried ID of the access key used to authenticate with the AWS API
- var: AWS_SECRET_ACCESS_KEY
description: Required secret of the access key used to authenticate with the AWS API
- var: AWS_REGION
description: Optional region used for all commands unless one is provided via the -r,--region flag
- var: AWS_STS_ROLE_ARN
description: Optional AWS IAM role ARN to assume before interacting with the AWS APIs.
homepage: https://github.com/cogcmd/aws-ec2
author: Patrick Van Stee <patrick@operable.io>
commands:
instance-create:
executable: /home/bundle/cog-command
description: Creates instances
long_description: >
Creates and starts an EC2 instance with the given image id. You'll most
likely need to set the image id, subnet id, instance type and keypair for
most invocations. Also, setting a Name tag so the instance can easily be
identified in the AWS console is recommended.
examples: |
Creating a simple instance:
```
ec2:instance-create -i ami-d481fad3 -s subnet-f365e3aa -m t2.nano -k production-key```
Creating an instance with tags (with basic flags above omitted):
```
ec2:instance-create -t "Name=super-server" -t "Color=red"```
rules:
- must have ec2:write
options:
image-id:
type: string
required: true
description: ID of the AMI. Run ec2:image-list for list of available AMIs.
short_flag: i
instance-type:
type: string
required: false
description: "Type of instance. Defaults to m1.small. Available types: t1.micro, t2.nano, t2.micro, t2.small, t2.medium, t2.large, m1.small, m1.medium, m1.large, m1.xlarge, m3.medium, m3.large, m3.xlarge, m3.2xlarge, m4.large, m4.xlarge, m4.2xlarge, m4.4xlarge, m4.10xlarge, m4.16xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, cr1.8xlarge, r3.large, r3.xlarge, r3.2xlarge, r3.4xlarge, r3.8xlarge, x1.16xlarge, x1.32xlarge, i2.xlarge, i2.2xlarge, i2.4xlarge, i2.8xlarge, hi1.4xlarge, hs1.8xlarge, c1.medium, c1.xlarge, c3.large, c3.xlarge, c3.2xlarge, c3.4xlarge, c3.8xlarge, c4.large, c4.xlarge, c4.2xlarge, c4.4xlarge, c4.8xlarge, cc1.4xlarge, cc2.8xlarge, g2.2xlarge, g2.8xlarge, cg1.4xlarge, p2.xlarge, p2.8xlarge, p2.16xlarge, d2.xlarge, d2.2xlarge, d2.4xlarge, d2.8xlarge."
short_flag: m
key-name:
type: string
required: false
description: Name of the key pair.
short_flag: k
availability-zone:
type: string
required: false
description: Availbility Zone inside the region specified.
short_flag: z
subnet-id:
type: string
required: false
description: ID of the subnet. Used within a VPC.
short_flag: s
tags:
type: string
required: false
description: Tags to assign Defined with the following pattern <key>=<value>.
short_flag: t
count:
type: int
required: false
description: Number of instances to create. Defaults to 1
short_flag: c
region:
type: string
required: false
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
short_flag: r
instance-list:
executable: /home/bundle/cog-command
description: Lists instances
long_description: >
Returns attributes of all instances in the specified (or default) region.
If you want to search for a specific instance or set of instances see the
`ec2:instance-search` command. When viewing the results in Slack, the
template will use an attachment color representing the current state of
each instance similar to the state badges in the AWS console.
rules:
- must have ec2:read
options:
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
instance-search:
executable: /home/bundle/cog-command
description: Searches instances with matching attributes
long_description: >
Applies filters to all the instances in the specified (or default)
region. Filters are defined as arguments matching the pattern
<key>=<value> where <key> is the name of the attribute of the instance
and <value> is value of that attribute to match against. If multiple
filters are provided, filters with the same key are ORed together while
all other filters are ANDed together.
examples: |
Finding instances of type t2.small in either the running or pending state:
```
ec2:instance-search "instance-type=t2.small" "instance-state-name=running" "instance-state-name=pending"```
Finding an instance by id:
```
ec2:instance-search "instance-id=i-191ea1bc"```
arguments: "[<filter> ...]"
rules:
- must have ec2:read
options:
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
instance-destroy:
executable: /home/bundle/cog-command
description: Destroys existing instances
long_description: >
Shuts down and removes instances. This operation will succeed even if the
instance is already being terminated. Terminated instances will also
remain in results from ec2:instance-list for about and hour, but their
state will be set to terminated.
arguments: "<instance-id> [<instance-id> ...]"
rules:
- must have ec2:admin
options:
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
instance-start:
executable: /home/bundle/cog-command
description: Starts existing instances
arguments: "<instance-id> [<instance-id> ...]"
rules:
- must have ec2:write
options:
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
instance-stop:
executable: /home/bundle/cog-command
description: Stops instances
arguments: "<instance-id> [<instance-id> ...]"
rules:
- must have ec2:write
options:
force:
type: bool
required: false
short_flag: f
description: Forces an instance to stop immediately. File system caches and metadata are not flushed.
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
instance-reboot:
executable: /home/bundle/cog-command
description: Reboots instances
arguments: "<instance-id> [<instance-id> ...]"
rules:
- must have ec2:write
options:
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
instance-tag:
executable: /home/bundle/cog-command
description: Tags an instance
long_description: >
Adds tags to an instance. One or more tags can be included as arguments
after the instance id. Each tag should be in the format <key>=<value>.
Because tag names are unique per resource, providing a tag that already
exists will overwrite the existing tag value. To avoid any parsing errors
wrapping each tag argument in quotes is recommended.
examples: |
Setting a few tags:
```
ec2:instance-tag i-191ea1bc "Erlang=R19B1" "Elixir=1.3.4"```
Updating an existing tag:
```
ec2:instance-tag i-191ea1bc "Name=New Fancy Server"```
arguments: "<instance-id> <tag> [<tag> ..]"
rules:
- must have ec2:write
options:
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
keypair-list:
executable: /home/bundle/cog-command
description: Lists keypairs
rules:
- must have ec2:read
options:
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
vpc-list:
executable: /home/bundle/cog-command
description: Lists VPCs
rules:
- must have ec2:read
options:
region:
type: string
required: false
short_flag: r
description: EC2 location to connect to (us-east-1, us-west-2, us-west-1, eu-west-1, eu-central-1, ap-southeast-1, ap-northeast-1, ap-southeast-2, ap-northeast-2, ap-south-1, sa-east-1)
permissions:
- ec2:read
- ec2:write
- ec2:admin
templates:
instance_list:
body: |
~each var=$results as=instance~
~attachment color=$instance.state.color~
~if cond=$instance.tags.Name bound?~**Instance Name:** ~$instance.tags.Name~
~end~
**Instance ID:** ~$instance.instance_id~
**Instance Type:** ~$instance.instance_type~
**Availability Zone:** ~$instance.placement.availability_zone~
**Instance State:** ~$instance.state.name~
**Public DNS:** ~$instance.public_dns_name~
**Public IP:** ~$instance.public_ip_address~
**Key Name** ~$instance.key_name~
**Launch Time** ~$instance.launch_time~
~end~
~end~
instance_start:
body: |
~each var=$results as=instance~
Started instance ~$instance.instance_id~
~end~
instance_destroy:
body: |
~each var=$results as=instance~
Destroyed instance ~$instance.instance_id~
~end~
instance_stop:
body: |
~each var=$results as=instance~
Stopped instance ~$instance.instance_id~
~end~
instance_reboot:
body: |
~each var=$results as=instance~
Rebooted instance ~$instance.instance_id~
~end~
instance_tag:
body: |
~each var=$results as=instance~
~each var=$instance.tags as=tag~
Tagged instance ~$instance.instance_id~ with ~$tag.key~=~$tag.value~
~end~
~end~
keypair_list:
body: |
| Key Name | Fingerprint |
| -------- | ----------- |
~each var=$results as=keypair~
| ~$keypair.key_name~ | ~$keypair.key_fingerprint~ |
~end~
vpc_list:
body: |
~each var=$results as=vpc~
~attachment color=$vpc.state.color~
~if cond=$instance.tags.Name bound?~**VPC Name:** ~$vpc.tags.Name~
~end~
**VPC ID:** ~$vpc.vpc_id~
**VPC State:** ~$vpc.state.name~
**VPC CIDR:** ~$vpc.cidr_block~
**DHCP Options Set:** ~$vpc.dhcp_options_id~
**Tenancy:** ~$vpc.instance_tenancy~
**Default VPC:** ~$vpc.is_default~
~end~
~end~