lono 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6375e08e65be7c8a3a1eec9356454c1975a40400
4
- data.tar.gz: 753b81d7bc5b3d1b5dd6fab7ed01858db6aeb7e0
3
+ metadata.gz: 106d4c92c775431a3051cc004dfe7725b2733b53
4
+ data.tar.gz: b690d54d0f64f80807aabda7506b415685899c2c
5
5
  SHA512:
6
- metadata.gz: c1e1f22813a7e5ab6444aafc53d21fc6dfec39b71ea2992d027e832429283a196360a4e9dabbc839b9b1d7e24800c322ffb49df9627662e6687e8c543008d2c7
7
- data.tar.gz: 05f0f728a8e87110ee5641ce3f0da27ebbcb12719e3b619eccb2dc634b9df156536ebbccc1a95581be1f300280a291c3d332f23cc4bb3a2e3abb5e387926ff5a
6
+ metadata.gz: 2af3a0be29c29ed36cca3d399050405a4867b1a0a7ca0d61d35678216b4f319d4bea2917b31928809b199fb5ddb203c35c1a281f61f600f8888434a23094bcf6
7
+ data.tar.gz: d7aa6c1712326065dc041b544219ddd85f4237ec0c15880bb28b80b3b2f6eab7470c0a18412ab830b423624c0795c1386698c216b5f989994690603ac86a72cb
@@ -2,4 +2,4 @@ language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
4
  - 2.2.5
5
- - 2.3.1
5
+ - 2.3.3
@@ -3,11 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [1.0.1]
7
+ - update starter project instance type allowed values
8
+
6
9
  ## [1.0.0]
7
10
  - Yaml support added! Makes for much more clean and concise templates. The `lono new` command defaults to yaml format.
8
11
  - The starter project is app centric instead of env centric. Example: blog-web-prod vs prod-blog-web.
9
12
 
10
-
11
13
  ## [0.5.2]
12
14
  - Add helper encode_base64 method in case you want to base64 encode a string in the ERB template and you are using lono outside of the context of CloudFormation where you will not have access to the FN::Base64 Function.
13
15
 
@@ -17,5 +19,5 @@ This project *tries* to adhere to [Semantic Versioning](http://semver.org/), eve
17
19
  ## [0.5.0]
18
20
 
19
21
  - Update use newer ruby syntax.
20
- - Get rid of the core Hash extension that is causing issues with aws-sdk version 2. I original did this because the output of the generated json files was no deterministic with ruby 1.8.7. No longer supporting ruby 1.8.7.
22
+ - Get rid of the core Hash extension that is causing issues with aws-sdk version 2. I original did this because the output of the generated json files was no deterministic with ruby 1.8.7. No longer supporting ruby 1.8.7.
21
23
  - Gem has been tested with ruby 2.2.5+
data/README.md CHANGED
@@ -12,7 +12,11 @@
12
12
  [3]: https://codeclimate.com/repos/51d7f1407e00a4042c010ab4/badges/5273fe6cdb5a13e58554/gpa.png
13
13
  [4]: https://codeclimate.com/repos/51d7f1407e00a4042c010ab4/feed
14
14
 
15
- Lono is a CloudFormation Template generator. Lono generates CloudFormation templates based on ERB ruby templates.
15
+ Lono is a CloudFormation Template generator. Lono generates CloudFormation templates based on ERB ruby templates in either `yaml` or `json` format.
16
+
17
+ **UPDATE**: lono now supports yaml format for CloudFormation! The old json format is still supported. For current projects, you do not have to change anything as the format is autodetected as part of `lono generate`.
18
+
19
+ Newly generated projects with `lono new infra` will use the yaml format by default. If you prefer the json format use `lono new --format json infra`. You cannot mix and match json and yaml format in one project, it's either all json or yaml. If any one has questions feel free to ping me: tongueroo@gmail.com.
16
20
 
17
21
  ## Usage
18
22
 
@@ -29,7 +33,7 @@ $ lono generate
29
33
 
30
34
  This generates the templates in the `config` and `templates` folders to the `output` folder.
31
35
 
32
- The starter lono template project config files looks like [this](lib/starter_project/config/lono.rb) and [this](lib/starter_project/config/lono/api.rb). Here's a snippet from one of the config files with the template call:
36
+ The starter lono template project config files looks like [this](lib/starter_project_yaml/config/lono.rb) and [this](lib/starter_project_yaml/config/lono/api.rb). Here's a snippet from one of the config files: [config/lono.rb](lib/starter_project_yaml/config/lono.rb).
33
37
 
34
38
  ```ruby
35
39
  template "api-web-prod.yml" do
@@ -55,10 +59,10 @@ template "api-web-prod.yml" do
55
59
  end
56
60
  ```
57
61
 
58
- The corresponding ERB template looks like the following. Note that some of the output has been shorten for brevity.
62
+ Here is the corresponding ERB template [templates/web.yml.erb](lib/starter_project_yaml/templates/web.yml.erb). Note that some of the source code has been shorten for brevity.
59
63
 
60
64
  ```yaml
61
- <% @app,@role,@env = name.sub('.yml','').split('-') %>
65
+ <% @app,@role,@env = name.sub('.yml','').split('-') -%>
62
66
  ---
63
67
  AWSTemplateFormatVersion: '2010-09-09'
64
68
  Description: <%= @app.capitalize %> Stack
@@ -98,7 +102,7 @@ Resources:
98
102
 
99
103
  ```
100
104
 
101
- The output looks like this:
105
+ The generated `output/blog-web-prod.yml` CloudFormation template looks like this:
102
106
 
103
107
  ```yaml
104
108
  ---
@@ -158,137 +162,12 @@ Resources:
158
162
 
159
163
  There are helper methods that are available in templates.
160
164
 
161
- * partial(relative_path, variables, options) - can be use to embed other files in a template. The partial view should be placed in the `templates/partial` folder of the project. So:
165
+ * partial(relative_path, variables, options) - Can be use to embed other files in a template. The partial view should be placed in the `templates/partial` folder of the project. So:
162
166
  * partial('launch\_config.json.erb') -> `templates/partial/launch_config.json.erb`
163
167
  * partial('launch\_config.json.erb', foo: "bar", hello: "world") - variables can be passed to the partial helper method are available to the partial as instance variables. So, in this case `@foo` and `@hello` will be available in the `launch_config.json.erb` partial.
164
168
  * partial('user_data/bootstrap.sh.erb', {}, indent: 10) - Indent the result partial by 10 spaces. Useful for yaml format.
165
169
 
166
- ## user\_data helper for json format
167
-
168
- The user\_data helper method is helpful for writting a script in bash form and having lono convert it to a json compatiable format. It is only really useful if you are using json as the CloudFormation format. If you are using yaml as the format, which is recommended, then you should simply use raw yaml.
169
-
170
- * user\_data - can be used to include a user data script which is written in bash script form. The user data script should be placed in the `templates/user_data` folder of the project. So:
171
- * user\_data('bootstrap.sh.erb') -> templates/user\_data/bootstrap.sh.erb
172
- * user\_data('db.sh.erb') -> templates/user\_data/db.sh.erb
173
- * user\_data('script1.sh.erb', foo: "bar", hello: "world") - variables can be passed to the user\_data helper method and will be available to the partial as instance variables. So, in this case `@foo` and `@hello` will be available in `script1.sh.erb`.
174
-
175
- Here's how you would call it in the template.
176
-
177
- ```json
178
- "UserData": {
179
- "Fn::Base64": {
180
- "Fn::Join": [
181
- "",
182
- [
183
- <%= user_data('db.sh.erb') %>
184
- ]
185
- ]
186
- }
187
- ```
188
-
189
- Within the user\_data script you can use helper methods that correspond to CloudFormation [Instrinic Functions](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/concept-intrinsic-functions.html). Currently, `base64`, `find_in_map`, `get_att`, `get_azs`, `join`, and `ref` are supported. Here's a short example of a user\_data script using a helper method:
190
-
191
- If you have a `templates/user_data/db.sh.erb` that looks like this:
192
-
193
- ```bash
194
- #!/bin/bash -lexv
195
-
196
- HOSTNAME_PREFIX=<%= find_in_map("EnvironmentMapping", "HostnamePrefix", ref("Environment")) %>
197
-
198
- echo <%= ref("AWS::StackName") %> > /tmp/stack_name
199
- # Helper function
200
- function error_exit
201
- {
202
- /usr/local/bin/cfn-signal -e 1 -r "$1" '<%= ref("WaitHandle") %>'
203
- exit 1
204
- }
205
- # Wait for the EBS volume to show up
206
- while [ ! -e /dev/xvdf ]; do echo Waiting for EBS volume to attach; sleep 1; done
207
- /bin/mkdir /media/redis
208
- /sbin/mkfs -t ext4 /dev/xvdf
209
- echo "/dev/xvdf /media/redis auto defaults 0 0" >> /etc/fstab
210
- /bin/mount /media/redis
211
- /usr/bin/redis-cli shutdown
212
- sleep 10
213
- mv /var/lib/redis/* /media/redis/
214
- rm -r /var/lib/redis
215
- ln -s /media/redis /var/lib/redis
216
- chown -R redis:redis /var/lib/redis
217
- chown -R redis:redis /media/redis
218
- /usr/bin/redis-server
219
- # If all is well so signal success
220
- /usr/local/bin/cfn-signal -e $? -r "Ready to rock" '<%= ref("WaitHandle") %>'
221
- ```
222
-
223
- The user\_data helper will transform the bash script into a json array of elements for CloudFormation:
224
-
225
- ```json
226
- [
227
- "#!/bin/bash -lexv\n",
228
- "\n",
229
- "HOSTNAME_PREFIX=",
230
- {
231
- "Fn::FindInMap": [
232
- "EnvironmentMapping",
233
- "HostnamePrefix",
234
- {
235
- "Ref": "Environment"
236
- }
237
- ]
238
- },
239
- "\n",
240
- "\n",
241
- "echo ",
242
- {
243
- "Ref": "AWS::StackName"
244
- },
245
- " > /tmp/stack_name\n",
246
- "# Helper function\n",
247
- "function error_exit\n",
248
- "{\n",
249
- " /usr/local/bin/cfn-signal -e 1 -r \"$1\" '",
250
- {
251
- "Ref": "WaitHandle"
252
- },
253
- "'\n",
254
- "exit 1\n",
255
- "}\n",
256
- "# Wait for the EBS volume to show up\n",
257
- "while [ ! -e /dev/xvdf ]; do echo Waiting for EBS volume to attach; sleep 1; done\n",
258
- "/bin/mkdir /media/redis\n",
259
- "/sbin/mkfs -t ext4 /dev/xvdf\n",
260
- "echo \"/dev/xvdf /media/redis auto defaults 0 0\" >> /etc/fstab\n",
261
- "/bin/mount /media/redis\n",
262
- "/usr/bin/redis-cli shutdown\n",
263
- "sleep 10\n",
264
- "mv /var/lib/redis/* /media/redis/\n",
265
- "rm -r /var/lib/redis\n",
266
- "ln -s /media/redis /var/lib/redis\n",
267
- "chown -R redis:redis /var/lib/redis\n",
268
- "chown -R redis:redis /media/redis\n",
269
- "/usr/bin/redis-server\n",
270
- "# If all is well so signal success\n",
271
- "/usr/local/bin/cfn-signal -e $? -r \"Ready to rock\" '",
272
- {
273
- "Ref": "WaitHandle"
274
- },
275
- "'\n"
276
- ]
277
- ```
278
-
279
- More examples of user\_data and instrinic function helper method usage are found in the starter [project template](https://github.com/tongueroo/lono/blob/master/lib/starter_project_json/templates/user_data/db.sh.erb)
280
-
281
- ## Converting UserData scripts
282
-
283
- You can convert UserData scripts in existing CloudFormation Templates to a starter bash script via:
284
-
285
- <pre>
286
- $ lono bashify cloud_formation_template.json
287
- $ lono bash cloud_formation_template.json # shorthand
288
- $ lono b https://s3.amazonaws.com/cloudformation-templates-us-east-1/LAMP_Single_Instance.template # shorthand and url
289
- </pre>
290
-
291
- This is useful if you want to take an existing json [CloudFormation Template example](http://aws.amazon.com/cloudformation/aws-cloudformation-templates/) and quicklly change the UserData section into a bash script. The bashify command will generate a snippet that is meant to be copied and pasted into a bash script and used with user\_data helper method. The bash script should work right off the bat as lono will transform the generated CloudFormation object references to json objects, there's no need to manually change what is generated to the helper methods, though you can if you prefer the look of the helper methods.
170
+ * user\_data - Helpful if you are using CloudFormation json format. More info on the [wiki page](https://github.com/tongueroo/lono/wiki/user_data-helper-for-json-format).
292
171
 
293
172
  ## Breaking up config/lono.rb
294
173
 
@@ -317,6 +196,8 @@ Running `lono generate` and building up the `aws cloudformation create-stack` co
317
196
  ```
318
197
  $ lono-cfn create mystack-$(date +%Y%m%d%H%M%S) --template mystack --params mystack
319
198
  $ lono-cfn create mystack-$(date +%Y%m%d%H%M%S) # shorthand if template and params file matches.
199
+ $ lono-cfn update mystack-1493859659
200
+ $ lono-cfn delete mystack-1493859659
320
201
  ```
321
202
 
322
203
  More info about lono-cfn here: [lono-cfn](https://github.com/tongueroo/lono-cfn) - Wrapper cfn tool to quickly create CloudFormation stacks from lono templates and params files.
@@ -1,3 +1,3 @@
1
1
  module Lono
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -27,19 +27,6 @@ Parameters:
27
27
  Type: String
28
28
  InstanceType:
29
29
  AllowedValues:
30
- - t1.micro
31
- - m1.small
32
- - m1.medium
33
- - m1.large
34
- - m1.xlarge
35
- - m2.xlarge
36
- - m2.2xlarge
37
- - m2.4xlarge
38
- - c1.medium
39
- - c1.xlarge
40
- - cc1.4xlarge
41
- - cc2.8xlarge
42
- - cg1.4xlarge
43
30
  - t2.nano
44
31
  - t2.micro
45
32
  - t2.small
@@ -53,6 +40,20 @@ Parameters:
53
40
  - m4.4xlarge
54
41
  - m4.10xlarge
55
42
  - m4.16xlarge
43
+ - m3.medium
44
+ - m3.large
45
+ - m3.xlarge
46
+ - m3.2xlarge
47
+ - c4.large
48
+ - c4.xlarge
49
+ - c4.2xlarge
50
+ - c4.4xlarge
51
+ - c4.8xlarge
52
+ - c3.large
53
+ - c3.xlarge
54
+ - c3.2xlarge
55
+ - c3.4xlarge
56
+ - c3.8xlarge
56
57
  ConstraintDescription: must be a valid EC2 instance type.
57
58
  Default: <%= @instance_type %>
58
59
  Description: WebServer EC2 instance type
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lono
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-04 00:00:00.000000000 Z
11
+ date: 2017-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake