ec2-host 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,95 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>
7
+ File: LICENSE
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!file.LICENSE.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index</a> &raquo;
35
+ <span class="title">File: LICENSE</span>
36
+
37
+
38
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
39
+ </div>
40
+
41
+ <div id="search">
42
+
43
+ <a class="full_list_link" id="class_list_link"
44
+ href="class_list.html">
45
+ Class List
46
+ </a>
47
+
48
+ <a class="full_list_link" id="method_list_link"
49
+ href="method_list.html">
50
+ Method List
51
+ </a>
52
+
53
+ <a class="full_list_link" id="file_list_link"
54
+ href="file_list.html">
55
+ File List
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <iframe id="search_frame"></iframe>
63
+
64
+ <div id="content"><div id='filecontents'>
65
+ <p>Copyright © 2015 Naotoshi Seo</p>
66
+
67
+ <p>MIT License</p>
68
+
69
+ <p>Permission is hereby granted, free of charge, to any person obtaining a
70
+ copy of this software and associated documentation files (the “Software”),
71
+ to deal in the Software without restriction, including without limitation
72
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
73
+ and/or sell copies of the Software, and to permit persons to whom the
74
+ Software is furnished to do so, subject to the following conditions:</p>
75
+
76
+ <p>The above copyright notice and this permission notice shall be included in
77
+ all copies or substantial portions of the Software.</p>
78
+
79
+ <p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
80
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
81
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
82
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
83
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
84
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
85
+ DEALINGS IN THE SOFTWARE.</p>
86
+ </div></div>
87
+
88
+ <div id="footer">
89
+ Generated on Thu Nov 24 10:25:36 2016 by
90
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
91
+ 0.8.7.6 (ruby-2.3.2).
92
+ </div>
93
+
94
+ </body>
95
+ </html>
@@ -0,0 +1,323 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!file.README.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index</a> &raquo;
35
+ <span class="title">File: README</span>
36
+
37
+
38
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
39
+ </div>
40
+
41
+ <div id="search">
42
+
43
+ <a class="full_list_link" id="class_list_link"
44
+ href="class_list.html">
45
+ Class List
46
+ </a>
47
+
48
+ <a class="full_list_link" id="method_list_link"
49
+ href="method_list.html">
50
+ Method List
51
+ </a>
52
+
53
+ <a class="full_list_link" id="file_list_link"
54
+ href="file_list.html">
55
+ File List
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <iframe id="search_frame"></iframe>
63
+
64
+ <div id="content"><div id='filecontents'>
65
+ <h1 id="label-ec2-host">ec2-host</h1>
66
+
67
+ <p>Search hosts on AWS EC2</p>
68
+
69
+ <h2 id="label-Installation">Installation</h2>
70
+
71
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_ec2'>ec2</span><span class='op'>-</span><span class='id identifier rubyid_host'>host</span>
72
+ </code></pre>
73
+
74
+ <h2 id="label-How+it+works">How it works</h2>
75
+
76
+ <p>This gems uses <a
77
+ href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html">tagging
78
+ of EC2 resources</a>. You can configure, but basically use
79
+ <code>Name</code> tag for hostname (this is default of EC2) and
80
+ <code>Roles</code> tag for roles.</p>
81
+
82
+ <p>You can manage roles of a host, and search hosts having a specified role
83
+ using thease tags with this gem.</p>
84
+
85
+ <h2 id="label-Configuration">Configuration</h2>
86
+
87
+ <p>You can write a configuration file located at
88
+ <code>/etc/sysconfig/ec2-host</code> (You can configure this path by
89
+ <code>EC2_HOST_CONFIG_FILE</code> environment variable), or as environment
90
+ variables:</p>
91
+
92
+ <p>AWS SDK (CLI) parameters:</p>
93
+ <ul><li>
94
+ <p><strong>AWS_ACCESS_KEY_ID</strong>: AWS SDK (CLI) crendentials. Default
95
+ loads a credentials file</p>
96
+ </li><li>
97
+ <p><strong>AWS_SECRET_ACCESS_KEY</strong>: AWS SDK (CLI) credentials. Default
98
+ load a credentials file</p>
99
+ </li><li>
100
+ <p><strong>AWS_DEFAULT_REGION</strong> (<strong>AWS_REGION</strong>); AWS SDK
101
+ (CLI) region such as <code>ap-northeast-1</code>, <code>us-east-1</code>.</p>
102
+ </li><li>
103
+ <p><strong>AWS_DEFAULT_PROFILE</strong> (<strong>AWS_PROFILE</strong>): The
104
+ profile key of the AWS SDK (CLI) credentails file. Default is
105
+ <code>default</code></p>
106
+ </li><li>
107
+ <p><strong>AWS_CREDENTIAL_FILE</strong>
108
+ (<strong>AWS_CREDENTIALS_FILE</strong>): Path of the AWS SDK (CLI)
109
+ credentails file. Default is <code>$HOME/.aws/credentials</code>. See <a
110
+ href="http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files">Configuring
111
+ the AWS Command Line Interface</a> for details.</p>
112
+ </li></ul>
113
+
114
+ <p>ec2-host parameters:</p>
115
+ <ul><li>
116
+ <p><strong>HOSTNAME_TAG (optional)</strong>: EC2 tag key used to express a
117
+ hostname. The default is <code>Name</code>.</p>
118
+ </li><li>
119
+ <p><strong>ROLES_TAG (optional)</strong>: EC2 tag keys used to express roles.
120
+ The default is <code>Roles</code></p>
121
+ </li><li>
122
+ <p>You can assign multiple roles seperated by <code>ARRAY_TAG_DELIMITER</code>
123
+ (default: <code>,</code>)</p>
124
+ </li><li>
125
+ <p>Also, you can express levels of roles delimited by
126
+ <code>ROLE_TAG_DELIMITER</code> (default <code>:</code>)</p>
127
+ </li><li>
128
+ <p>Example: admin:ami, then <code>EC2::Host.new(role:
129
+ &#39;admin:ami&#39;)</code> and also <code>EC2::Host.new(role1:
130
+ &#39;admin&#39;)</code> returns this host</p>
131
+ </li><li>
132
+ <p><strong>ROLE_TAG_DELIMITER (optional)</strong>: A delimiter to express
133
+ levels of roles. Default is <code>:</code></p>
134
+ </li><li>
135
+ <p><strong>OPTIONAL_STRING_TAGS (optional)</strong>: You may add optional
136
+ non-array tags. You can specify multiple tags like
137
+ <code>Service,Status</code>.</p>
138
+ </li><li>
139
+ <p><strong>OPTIONAL_ARRAY_TAGS (optional)</strong>: You may add optional array
140
+ tags. Array tags allows multiple values delimited by
141
+ <code>ARRAY_TAG_DELIMITER</code> (default: <code>,</code>)</p>
142
+ </li><li>
143
+ <p><strong>ARRAY_TAG_DELIMITER (optional)</strong>: A delimiter to express
144
+ array. Default is <code>,</code></p>
145
+ </li><li>
146
+ <p><strong>LOG_LEVEL (optional)</strong>: Log level such as <code>info</code>,
147
+ <code>debug</code>, <code>error</code>. The default is <code>info</code>.</p>
148
+ </li></ul>
149
+
150
+ <p>See <a href="./example/example.conf">example.conf</a></p>
151
+
152
+ <h2 id="label-Tag+Example">Tag Example</h2>
153
+ <ul><li>
154
+ <p><strong>Name</strong>: hostname</p>
155
+ </li><li>
156
+ <p><strong>Roles</strong>: app:web,app:db</p>
157
+ </li><li>
158
+ <p><strong>Service</strong>: sugoi</p>
159
+ </li><li>
160
+ <p><strong>Status</strong>: setup</p>
161
+ </li></ul>
162
+
163
+ <h2 id="label-CLI+Usage">CLI Usage</h2>
164
+
165
+ <h3 id="label-CLI+Example">CLI Example</h3>
166
+
167
+ <pre class="code ruby"><code class="ruby">$ ec2-host -j
168
+ {&quot;hostname&quot;:&quot;test&quot;,&quot;roles&quot;:[&quot;admin:ami&quot;,&quot;test&quot;],&quot;region&quot;:&quot;ap-northeast-1&quot;,&quot;instance_id&quot;:&quot;i-85900780&quot;,&quot;private_ip_address&quot;:&quot;172.31.23.50&quot;,&quot;public_ip_address&quot;:null,&quot;launch_time&quot;:&quot;2013-09-16 06:14:20 UTC&quot;,&quot;state&quot;:&quot;running&quot;,&quot;monitoring&quot;:&quot;disabled&quot;}
169
+ {&quot;hostname&quot;:&quot;ip-172-31-6-194&quot;,&quot;roles&quot;:[&quot;isucon4:qual&quot;],&quot;region&quot;:&quot;ap-northeast-1&quot;,&quot;instance_id&quot;:&quot;i-f88cc8e1&quot;,&quot;private_ip_address&quot;:&quot;172.31.6.194&quot;,&quot;public_ip_address&quot;:null,&quot;launch_time&quot;:&quot;2014-10-20 15:57:23 UTC&quot;,&quot;state&quot;:&quot;running&quot;,&quot;monitoring&quot;:&quot;disabled&quot;}</code></pre>
170
+
171
+ <pre class="code ruby"><code class="ruby">$ ec2-host
172
+ test
173
+ ip-172-31-6-194 # if Name tag is not available</code></pre>
174
+
175
+ <pre class="code ruby"><code class="ruby">$ ec2-host --role1 admin
176
+ test</code></pre>
177
+
178
+ <pre class="code ruby"><code class="ruby">$ ec2-host --role admin:ami
179
+ test</code></pre>
180
+
181
+ <pre class="code ruby"><code class="ruby">$ ec2-host --pretty-json
182
+ [
183
+ {
184
+ &quot;hostname&quot;: &quot;test&quot;,
185
+ &quot;roles&quot;: [
186
+ &quot;admin:ami&quot;,
187
+ &quot;test&quot;
188
+ ],
189
+ &quot;region&quot;: &quot;ap-northeast-1&quot;,
190
+ &quot;instance_id&quot;: &quot;i-85900780&quot;,
191
+ &quot;private_ip_address&quot;: &quot;172.31.23.50&quot;,
192
+ &quot;public_ip_address&quot;: null,
193
+ &quot;launch_time&quot;: &quot;2013-09-16 06:14:20 UTC&quot;,
194
+ &quot;state&quot;: &quot;running&quot;,
195
+ &quot;monitoring&quot;: &quot;disabled&quot;
196
+ },
197
+ {
198
+ &quot;hostname&quot;: &quot;ip-172-31-6-194&quot;,
199
+ &quot;roles&quot;: [
200
+ &quot;isucon4:qual&quot;
201
+ ],
202
+ &quot;region&quot;: &quot;ap-northeast-1&quot;,
203
+ &quot;instance_id&quot;: &quot;i-f88cc8e1&quot;,
204
+ &quot;private_ip_address&quot;: &quot;172.31.6.194&quot;,
205
+ &quot;public_ip_address&quot;: null,
206
+ &quot;launch_time&quot;: &quot;2014-10-20 15:57:23 UTC&quot;,
207
+ &quot;state&quot;: &quot;running&quot;,
208
+ &quot;monitoring&quot;: &quot;disabled&quot;
209
+ }
210
+ ]</code></pre>
211
+
212
+ <h3 id="label-CLI+Help">CLI Help</h3>
213
+
214
+ <pre class="code ruby"><code class="ruby">$ bin/ec2-host --help
215
+ Usage: ec2-host [options]
216
+ --hostname one,two,three name or private_dns_name
217
+ -r, --role one,two,three role
218
+ --r1, --role1 one,two,three role1, the 1st part of role delimited by :
219
+ --r2, --role2 one,two,three role2, the 2st part of role delimited by :
220
+ --r3, --role3 one,two,three role3, the 3st part of role delimited by :
221
+ --instance-id one,two,three instance_id
222
+ --state one,two,three filter with instance state (default: running)
223
+ --monitoring one,two,three filter with instance monitoring
224
+ -a, --all list all hosts (remove default filter)
225
+ --private-ip, --ip show private ip address instead of hostname
226
+ --public-ip show public ip address instead of hostname
227
+ -i, --info show host info
228
+ -j, --jsonl show host info in line delimited json
229
+ --json show host info in json
230
+ --pretty-json show host info in pretty json
231
+ --debug debug mode
232
+ -h, --help show help</code></pre>
233
+
234
+ <h2 id="label-Library+Usage">Library Usage</h2>
235
+
236
+ <h3 id="label-Library+Example">Library Example</h3>
237
+
238
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ec2-host</span><span class='tstring_end'>&#39;</span></span>
239
+
240
+ <span class='id identifier rubyid_hosts'>hosts</span> <span class='op'>=</span> <span class='const'>EC2</span><span class='op'>::</span><span class='const'>Host</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>role:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>admin:ami</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
241
+ <span class='id identifier rubyid_hosts'>hosts</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_host'>host</span><span class='op'>|</span>
242
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_host'>host</span>
243
+ <span class='kw'>end</span>
244
+ </code></pre>
245
+
246
+ <h3 id="label-Library+Reference">Library Reference</h3>
247
+
248
+ <p>See <a
249
+ href="http://sonots.github.io/ec2-host/frames.html">sonots.github.io/ec2-host/frames.html</a>.</p>
250
+
251
+ <h2 id="label-ChangeLog">ChangeLog</h2>
252
+
253
+ <p>See <a href="CHANGELOG.md">CHANGELOG.md</a> for details.</p>
254
+
255
+ <h2 id="label-For+Developers">For Developers</h2>
256
+
257
+ <h3 id="label-ToDo">ToDo</h3>
258
+ <ul><li>
259
+ <p>Support assume-roles</p>
260
+ </li><li>
261
+ <p>Use mock/stub to run test (currently, directly accessing to EC2)</p>
262
+ </li><li>
263
+ <p>Should cache a result of describe-instances in like 30 seconds?</p>
264
+ </li></ul>
265
+
266
+ <h3 id="label-How+to+Run+test">How to Run test</h3>
267
+
268
+ <p>NOTE: Currently, mock is not supported yet. So, you have to create your own
269
+ AWS account, and instances.</p>
270
+
271
+ <p>Configure .env file as</p>
272
+
273
+ <pre class="code ruby"><code class="ruby">AWS_ACCESS_KEY_ID=
274
+ AWS_SECRET_ACCESS_KEY=
275
+ AWS_DEFAULT_REGION=
276
+ EC2_HOST_CONFIG_FILE=.env
277
+ OPTIONAL_ARRAY_TAGS=Tags
278
+ OPTIONAL_STRING_TAGS=Service,Status</code></pre>
279
+
280
+ <p>Install terraform and run to create instances for tests</p>
281
+
282
+ <pre class="code ruby"><code class="ruby">$ brew install terraform
283
+ $ env $(cat .env) terraform plan
284
+ $ env ($cat .env) terraform apply</code></pre>
285
+
286
+ <p>Run test</p>
287
+
288
+ <pre class="code ruby"><code class="ruby">$ bundle exec rspec</code></pre>
289
+
290
+ <p>After working, destory instances by commenting out
291
+ <code>terraform.tf</code> and apply.</p>
292
+
293
+ <h3 id="label-How+to+Release+Gem">How to Release Gem</h3>
294
+ <ol><li>
295
+ <p>Update gem.version in the gemspec</p>
296
+ </li><li>
297
+ <p>Update CHANGELOG.md</p>
298
+ </li><li>
299
+ <p>git commit &amp;&amp; git push</p>
300
+ </li><li>
301
+ <p>Run <code>bundle exec rake release</code></p>
302
+ </li></ol>
303
+
304
+ <h3 id="label-How+to+Update+doc">How to Update doc</h3>
305
+ <ol><li>
306
+ <p>Run <code>bundle exec yard</code></p>
307
+ </li><li>
308
+ <p>git commit &amp;&amp; git push</p>
309
+ </li></ol>
310
+
311
+ <h3 id="label-Licenses">Licenses</h3>
312
+
313
+ <p>See <a href="LICENSE">LICENSE</a></p>
314
+ </div></div>
315
+
316
+ <div id="footer">
317
+ Generated on Thu Nov 24 10:25:36 2016 by
318
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
319
+ 0.8.7.6 (ruby-2.3.2).
320
+ </div>
321
+
322
+ </body>
323
+ </html>
@@ -0,0 +1,63 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <script type="text/javascript" charset="utf-8">
23
+ var hasFrames = false;
24
+ try {
25
+ hasFrames = window.top.frames.main ? true : false;
26
+ } catch (e) { }
27
+ if (hasFrames) {
28
+ document.getElementById('base_target').target = 'main';
29
+ document.body.className = 'frames';
30
+ }
31
+ </script>
32
+ <div id="content">
33
+ <h1 id="full_list_header">File List</h1>
34
+ <div id="nav">
35
+
36
+ <span><a target="_self" href="class_list.html">
37
+ Classes
38
+ </a></span>
39
+
40
+ <span><a target="_self" href="method_list.html">
41
+ Methods
42
+ </a></span>
43
+
44
+ <span><a target="_self" href="file_list.html">
45
+ Files
46
+ </a></span>
47
+
48
+ </div>
49
+ <div id="search">Search: <input type="text" /></div>
50
+
51
+ <ul id="full_list" class="file">
52
+
53
+
54
+ <li class="r1"><span class="object_link"><a href="index.html" title="README">README</a></a></li>
55
+
56
+
57
+ <li class="r2"><span class="object_link"><a href="file.LICENSE.html" title="LICENSE">LICENSE</a></a></li>
58
+
59
+
60
+ </ul>
61
+ </div>
62
+ </body>
63
+ </html>