lono 4.2.7 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/README.md +6 -0
  3. data/.cody/acceptance.sh +30 -0
  4. data/.cody/buildspec.yml +21 -0
  5. data/.cody/demo.rb +38 -0
  6. data/.cody/project.rb +12 -0
  7. data/.cody/role.rb +1 -0
  8. data/.gitignore +2 -0
  9. data/.gitmodules +6 -3
  10. data/.travis.yml +7 -0
  11. data/CHANGELOG.md +10 -0
  12. data/Gemfile +0 -1
  13. data/LICENSE.txt +1 -22
  14. data/README.md +46 -55
  15. data/lib/lono.rb +20 -27
  16. data/lib/lono/app_file.rb +5 -0
  17. data/lib/lono/app_file/base.rb +19 -0
  18. data/lib/lono/app_file/build.rb +78 -0
  19. data/lib/lono/app_file/registry.rb +14 -0
  20. data/lib/lono/app_file/registry/item.rb +46 -0
  21. data/lib/lono/app_file/upload.rb +39 -0
  22. data/lib/lono/autoloader.rb +22 -0
  23. data/lib/lono/aws_services.rb +46 -0
  24. data/lib/lono/aws_services/util.rb +49 -0
  25. data/lib/lono/blueprint.rb +113 -0
  26. data/lib/lono/blueprint/find.rb +90 -0
  27. data/lib/lono/blueprint/helper.rb +18 -0
  28. data/lib/lono/blueprint/info.rb +10 -0
  29. data/lib/lono/blueprint/list.rb +14 -0
  30. data/lib/lono/blueprint/root.rb +43 -0
  31. data/lib/lono/cfn.rb +31 -19
  32. data/lib/lono/cfn/aws_service.rb +16 -0
  33. data/lib/lono/cfn/base.rb +244 -261
  34. data/lib/lono/cfn/create.rb +36 -32
  35. data/lib/lono/cfn/current.rb +1 -1
  36. data/lib/lono/cfn/delete.rb +2 -2
  37. data/lib/lono/cfn/deploy.rb +11 -0
  38. data/lib/lono/cfn/diff.rb +1 -1
  39. data/lib/lono/cfn/preview.rb +3 -3
  40. data/lib/lono/cfn/rollback.rb +26 -0
  41. data/lib/lono/cfn/status.rb +2 -203
  42. data/lib/lono/cfn/suffix.rb +67 -0
  43. data/lib/lono/cfn/update.rb +61 -53
  44. data/lib/lono/cli.rb +42 -23
  45. data/lib/lono/completer.rb +0 -2
  46. data/lib/lono/configure.rb +37 -0
  47. data/lib/lono/configure/aws_services.rb +18 -0
  48. data/lib/lono/configure/base.rb +94 -0
  49. data/lib/lono/configure/helpers.rb +128 -0
  50. data/lib/lono/conventions.rb +11 -0
  51. data/lib/lono/core.rb +42 -12
  52. data/lib/lono/core/config.rb +5 -4
  53. data/lib/lono/default/settings.yml +0 -11
  54. data/lib/lono/file_uploader.rb +9 -4
  55. data/lib/lono/help.rb +1 -2
  56. data/lib/lono/help/blueprint.md +46 -0
  57. data/lib/lono/help/cfn.md +5 -4
  58. data/lib/lono/help/cfn/create.md +14 -9
  59. data/lib/lono/help/cfn/deploy.md +92 -0
  60. data/lib/lono/help/cfn/diff.md +0 -1
  61. data/lib/lono/help/cfn/update.md +16 -15
  62. data/lib/lono/help/completion.md +3 -3
  63. data/lib/lono/help/generate.md +0 -1
  64. data/lib/lono/help/new.md +40 -34
  65. data/lib/lono/help/param.md +1 -1
  66. data/lib/lono/help/param/generate.md +1 -1
  67. data/lib/lono/help/template.md +2 -2
  68. data/lib/lono/help/xgraph.md +1 -1
  69. data/lib/lono/inspector.rb +1 -1
  70. data/lib/lono/inspector/base.rb +26 -10
  71. data/lib/lono/inspector/graph.rb +7 -3
  72. data/lib/lono/inspector/summary.rb +15 -3
  73. data/lib/lono/md5.rb +46 -0
  74. data/lib/lono/new.rb +40 -28
  75. data/lib/lono/new/helper.rb +2 -3
  76. data/lib/lono/param.rb +12 -11
  77. data/lib/lono/param/generator.rb +96 -42
  78. data/lib/lono/project_checker.rb +27 -8
  79. data/lib/lono/s3.rb +23 -0
  80. data/lib/lono/s3/bucket.rb +123 -0
  81. data/lib/lono/script.rb +4 -8
  82. data/lib/lono/script/base.rb +7 -2
  83. data/lib/lono/script/build.rb +7 -8
  84. data/lib/lono/script/upload.rb +4 -20
  85. data/lib/lono/sequence.rb +19 -16
  86. data/lib/lono/setting.rb +19 -27
  87. data/lib/lono/template.rb +22 -26
  88. data/lib/lono/template/base.rb +13 -0
  89. data/lib/lono/template/context.rb +4 -56
  90. data/lib/lono/template/context/loader.rb +70 -0
  91. data/lib/lono/template/dsl.rb +15 -151
  92. data/lib/lono/template/dsl/builder.rb +60 -0
  93. data/lib/lono/template/dsl/builder/base.rb +14 -0
  94. data/lib/lono/template/dsl/builder/condition.rb +26 -0
  95. data/lib/lono/template/dsl/builder/fn.rb +114 -0
  96. data/lib/lono/template/dsl/builder/helper.rb +64 -0
  97. data/lib/lono/template/dsl/builder/mapping.rb +24 -0
  98. data/lib/lono/template/dsl/builder/output.rb +37 -0
  99. data/lib/lono/template/dsl/builder/parameter.rb +39 -0
  100. data/lib/lono/template/dsl/builder/resource.rb +38 -0
  101. data/lib/lono/template/dsl/builder/section.rb +12 -0
  102. data/lib/lono/template/dsl/builder/syntax.rb +58 -0
  103. data/lib/lono/template/erb.rb +82 -0
  104. data/lib/lono/template/evaluate.rb +39 -0
  105. data/lib/lono/template/generator.rb +29 -0
  106. data/lib/lono/template/helper.rb +7 -29
  107. data/lib/lono/template/post_processor.rb +69 -0
  108. data/lib/lono/template/template.rb +4 -9
  109. data/lib/lono/template/upload.rb +103 -133
  110. data/lib/lono/template/util.rb +48 -0
  111. data/lib/lono/upgrade.rb +5 -3
  112. data/lib/lono/upgrade/upgrade5.rb +55 -0
  113. data/lib/lono/user_data.rb +4 -4
  114. data/lib/lono/version.rb +1 -1
  115. data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +44 -0
  116. data/lib/templates/blueprint/.gitignore +14 -0
  117. data/lib/templates/blueprint/.lono/config.yml.tt +3 -0
  118. data/lib/templates/blueprint/.meta/config.yml.tt +3 -0
  119. data/lib/templates/blueprint/CHANGELOG.md +7 -0
  120. data/lib/templates/blueprint/Gemfile +4 -0
  121. data/lib/templates/blueprint/README.md +37 -0
  122. data/lib/templates/blueprint/Rakefile +6 -0
  123. data/lib/templates/blueprint/setup/configs.rb +54 -0
  124. data/lib/templates/blueprint_configs/configs/%blueprint_name%/params/base.txt +2 -0
  125. data/lib/{starter_projects/skeleton/app/definitions/base.rb → templates/blueprint_configs/configs/%blueprint_name%/params/development.txt} +0 -0
  126. data/lib/templates/blueprint_configs/configs/%blueprint_name%/variables/base.rb +2 -0
  127. data/lib/templates/blueprint_configs/configs/%blueprint_name%/variables/development.rb +0 -0
  128. data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +37 -0
  129. data/lib/templates/blueprint_types/dsl/app/user_data/bootstrap.sh +2 -0
  130. data/lib/templates/blueprint_types/erb/app/definitions/base.rb.tt +1 -0
  131. data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +8 -0
  132. data/lib/{starter_projects/autoscaling → templates/skeleton}/.gitignore +1 -0
  133. data/lib/templates/skeleton/Gemfile +3 -0
  134. data/lib/{starter_projects/autoscaling → templates/skeleton}/Guardfile +2 -2
  135. data/lib/templates/skeleton/README.md +58 -0
  136. data/lib/templates/skeleton/configs/settings.yml +17 -0
  137. data/lib/templates/upgrade5/blueprints/main/.lono/config.yml +3 -0
  138. data/lib/templates/upgrade5/blueprints/main/.meta/config.yml +3 -0
  139. data/lono.gemspec +12 -8
  140. data/vendor/cfn-status/CHANGELOG.md +10 -0
  141. data/vendor/cfn-status/Gemfile +4 -0
  142. data/vendor/cfn-status/LICENSE.txt +21 -0
  143. data/vendor/cfn-status/README.md +56 -0
  144. data/vendor/cfn-status/Rakefile +6 -0
  145. data/vendor/cfn-status/bin/console +14 -0
  146. data/vendor/cfn-status/bin/setup +8 -0
  147. data/vendor/cfn-status/cfn-status.gemspec +30 -0
  148. data/vendor/cfn-status/lib/cfn-status.rb +1 -0
  149. data/vendor/cfn-status/lib/cfn/aws_service.rb +51 -0
  150. data/vendor/cfn-status/lib/cfn/status.rb +219 -0
  151. data/vendor/cfn-status/lib/cfn/status/version.rb +5 -0
  152. data/vendor/cfn-status/spec/cfn/status_spec.rb +81 -0
  153. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +1080 -0
  154. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +1080 -0
  155. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +1086 -0
  156. data/vendor/cfn-status/spec/spec_helper.rb +14 -0
  157. data/vendor/cfn_camelizer/CHANGELOG.md +20 -0
  158. data/vendor/cfn_camelizer/Gemfile +4 -0
  159. data/vendor/cfn_camelizer/LICENSE.txt +21 -0
  160. data/vendor/cfn_camelizer/README.md +40 -0
  161. data/vendor/cfn_camelizer/Rakefile +6 -0
  162. data/vendor/cfn_camelizer/bin/console +14 -0
  163. data/vendor/cfn_camelizer/bin/setup +8 -0
  164. data/vendor/cfn_camelizer/cfn_camelizer.gemspec +32 -0
  165. data/vendor/cfn_camelizer/lib/camelizer.yml +37 -0
  166. data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +94 -0
  167. data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +3 -0
  168. data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +86 -0
  169. data/vendor/cfn_camelizer/spec/spec_helper.rb +14 -0
  170. metadata +189 -62
  171. data/.circleci/bin/commit_docs.sh +0 -26
  172. data/.circleci/config.yml +0 -72
  173. data/bin/release +0 -9
  174. data/lib/lono/help/import.md +0 -54
  175. data/lib/lono/importer.rb +0 -134
  176. data/lib/lono/new/message.rb +0 -35
  177. data/lib/starter_projects/autoscaling/Gemfile +0 -3
  178. data/lib/starter_projects/autoscaling/README.md +0 -118
  179. data/lib/starter_projects/autoscaling/app/definitions/base.rb +0 -2
  180. data/lib/starter_projects/autoscaling/app/templates/autoscaling.yml +0 -682
  181. data/lib/starter_projects/autoscaling/config/params/base/autoscaling.txt +0 -6
  182. data/lib/starter_projects/autoscaling/config/settings.yml +0 -33
  183. data/lib/starter_projects/ec2/.gitignore +0 -2
  184. data/lib/starter_projects/ec2/Gemfile +0 -3
  185. data/lib/starter_projects/ec2/Guardfile +0 -12
  186. data/lib/starter_projects/ec2/README.md +0 -86
  187. data/lib/starter_projects/ec2/app/definitions/base.rb +0 -2
  188. data/lib/starter_projects/ec2/app/definitions/development.rb +0 -1
  189. data/lib/starter_projects/ec2/app/definitions/production.rb +0 -1
  190. data/lib/starter_projects/ec2/app/helpers/my_custom_helper.rb +0 -17
  191. data/lib/starter_projects/ec2/app/partials/user_data/bootstrap.sh +0 -4
  192. data/lib/starter_projects/ec2/app/templates/example.yml +0 -430
  193. data/lib/starter_projects/ec2/config/params/base/example.txt +0 -2
  194. data/lib/starter_projects/ec2/config/params/development/example.txt +0 -3
  195. data/lib/starter_projects/ec2/config/params/production/example.txt +0 -2
  196. data/lib/starter_projects/ec2/config/settings.yml +0 -33
  197. data/lib/starter_projects/ec2/config/variables/base.rb +0 -3
  198. data/lib/starter_projects/ec2/config/variables/development.rb +0 -2
  199. data/lib/starter_projects/ec2/config/variables/production.rb +0 -2
  200. data/lib/starter_projects/ec2/welcome.txt +0 -8
  201. data/lib/starter_projects/skeleton/.gitignore +0 -2
  202. data/lib/starter_projects/skeleton/Gemfile +0 -3
  203. data/lib/starter_projects/skeleton/Guardfile +0 -12
  204. data/lib/starter_projects/skeleton/README.md +0 -53
  205. data/lib/starter_projects/skeleton/config/settings.yml +0 -33
  206. data/lib/starter_projects/skeleton/welcome.txt +0 -7
  207. data/vendor/plissken/Gemfile +0 -14
  208. data/vendor/plissken/LICENSE.txt +0 -20
  209. data/vendor/plissken/README.md +0 -46
  210. data/vendor/plissken/Rakefile +0 -56
  211. data/vendor/plissken/VERSION +0 -1
  212. data/vendor/plissken/lib/plissken.rb +0 -1
  213. data/vendor/plissken/lib/plissken/ext/hash/to_snake_keys.rb +0 -45
  214. data/vendor/plissken/plissken.gemspec +0 -61
  215. data/vendor/plissken/spec/lib/to_snake_keys_spec.rb +0 -177
  216. data/vendor/plissken/spec/spec_helper.rb +0 -90
  217. data/vendor/plissken/test/helper.rb +0 -20
  218. data/vendor/plissken/test/plissken/ext/hash/to_snake_keys_test.rb +0 -184
  219. data/vendor/plissken/test/test_plissken.rb +0 -2
@@ -1,26 +0,0 @@
1
- #!/bin/bash -eux
2
-
3
- # Even though specs also generate docs, lets run again to ensure clean slate
4
- rake docs
5
-
6
- out=$(git status docs)
7
- if [[ "$out" = *"nothing to commit"* ]]; then
8
- exit
9
- fi
10
-
11
- COMMIT_MESSAGE="docs updated by circleci"
12
-
13
- # If the last commit already updated the docs, then exit.
14
- # Preventable measure to avoid infinite loop.
15
- if git log -1 --pretty=oneline | grep "$COMMIT_MESSAGE" ; then
16
- exit
17
- fi
18
-
19
- # If reach here, we have some changes on docs that we should commit.
20
- # Even though s
21
- git add docs
22
- git commit -m "$COMMIT_MESSAGE"
23
-
24
- # https://makandracards.com/makandra/12107-git-show-current-branch-name-only
25
- current_branch=$(git rev-parse --abbrev-ref HEAD)
26
- git push origin "$current_branch"
@@ -1,72 +0,0 @@
1
- # Ruby CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
- #
5
- version: 2
6
- jobs:
7
- build:
8
- docker:
9
- # specify the version you desire here
10
- - image: circleci/ruby:2.5.0-node-browsers
11
-
12
- # Specify service dependencies here if necessary
13
- # CircleCI maintains a library of pre-built images
14
- # documented at https://circleci.com/docs/2.0/circleci-images/
15
- # - image: circleci/postgres:9.4
16
-
17
- working_directory: ~/repo
18
-
19
- steps:
20
- - checkout
21
-
22
- - run:
23
- name: submodule sync
24
- command: |
25
- git submodule sync
26
- git submodule update --init
27
-
28
- # Download and cache dependencies
29
- - restore_cache:
30
- keys:
31
- - v1-dependencies-{{ checksum "Gemfile" }}
32
- # fallback to using the latest cache if no exact match is found
33
- - v1-dependencies-
34
-
35
- - run:
36
- name: install dependencies
37
- command: |
38
- bundle install --jobs=4 --retry=3 --path vendor/bundle
39
-
40
- - save_cache:
41
- paths:
42
- - ./vendor/bundle
43
- key: v1-dependencies-{{ checksum "Gemfile" }}
44
-
45
- # specs need git configured ad commit_docs.sh required it also
46
- - run:
47
- name: configure git
48
- command: |
49
- git config --global user.email "tongueroo@gmail.com"
50
- git config --global user.name "Tung Nguyen"
51
-
52
- # run tests!
53
- - run:
54
- name: run tests
55
- command: |
56
- mkdir /tmp/test-results
57
- bundle exec rspec
58
-
59
- # The specs will generate reference docs.
60
- # Commit it again so that the reference docs are published to GitHub pages.
61
- - run:
62
- name: commit cli reference docs
63
- command: |
64
- chmod a+x -R .circleci/bin
65
- .circleci/bin/commit_docs.sh
66
-
67
- # collect reports
68
- - store_test_results:
69
- path: /tmp/test-results
70
- - store_artifacts:
71
- path: /tmp/test-results
72
- destination: test-results
@@ -1,9 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Wrapper release script so we don't forget to add submodules.
4
- # Should still update the CHANGELOG.md and version.rb before running this script.
5
-
6
- git submodule init
7
- git submodule update
8
- bundle update
9
- rake release
@@ -1,54 +0,0 @@
1
- ## Examples
2
-
3
- lono import /path/to/file --name my-stack
4
- lono import http://url.com/path/to/template.json --name my-stack
5
- lono import http://url.com/path/to/template.yml --name my-stack
6
-
7
- ## Example Output
8
-
9
- $ lono import https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/EC2InstanceWithSecurityGroupSample.template --name ec2
10
- => Imported CloudFormation template and lono-fied it.
11
- Template definition added to app/definitions/base.rb
12
- Params file created to config/params/base/ec2.txt
13
- Template downloaded to app/templates/ec2.yml
14
- => CloudFormation Template Summary:
15
- Parameters:
16
- Required:
17
- KeyName (AWS::EC2::KeyPair::KeyName)
18
- Optional:
19
- InstanceType (String) Default: t2.small
20
- SSHLocation (String) Default: 0.0.0.0/0
21
- Resources:
22
- 1 AWS::EC2::Instance
23
- 1 AWS::EC2::SecurityGroup
24
- 2 Total
25
- Here are contents of the params config/params/base/ec2.txt file:
26
- KeyName=
27
- #InstanceType= # optional
28
-
29
- ### Template name: CamelCase or dasherize
30
-
31
- If you do not specify the `--name` option, `lono import` sets a name based on the filename of the imported file. It converts the name to a dasherize version of the filename by default.
32
-
33
- You can specify whether or not to CamelCase or dasherize the name of the final template file with the `--casing` option. Examples:
34
-
35
- Dasherize:
36
-
37
- ```sh
38
- lono import https://s3.amazonaws.com/cloudformation-templates-us-east-1/EC2InstanceWithSecurityGroupSample.template --casing dasherize
39
- ```
40
-
41
- CamelCase:
42
-
43
- ```sh
44
- lono import https://s3.amazonaws.com/cloudformation-templates-us-east-1/EC2InstanceWithSecurityGroupSample.template --casing camelcase
45
- ```
46
-
47
- The default is dasherize.
48
-
49
- Question: You might be wondering, why does lono import uses dasherize vs underscore?
50
-
51
- Answer: I prefer filenames to be underscored. However, CloudFormation stack names do not allow underscores in their naming, so it is encourage to either dasherize or camelize your template names so the stack name and the template name can be the same.
52
-
53
- This blog post [Introducing the lono import Command](https://blog.boltops.com/2017/09/15/introducing-the-lono-import-command) also covers `lono import`.
54
-
@@ -1,134 +0,0 @@
1
- require "open-uri"
2
- require "json"
3
- require "yaml"
4
-
5
- class Lono::Importer
6
- attr_reader :options
7
- def initialize(source, options)
8
- @source = source
9
- @options = options
10
- @format = 'yml'
11
- Lono::ProjectChecker.check
12
- end
13
-
14
- def run
15
- unless options[:noop]
16
- download_template
17
- template_definition_path = add_template_definition
18
- create_params
19
- puts "=> Imported CloudFormation template and lono-fied it.".color(:green)
20
- puts "Template definition added to #{pretty_path(template_definition_path)}"
21
- puts "Params file created to #{pretty_path(params_path)}"
22
- end
23
- puts "Template downloaded to #{pretty_path(template_path)}" # like having this message at the end
24
-
25
- # at the end display some useful info for the user
26
- return unless options[:summary]
27
- summarize
28
- show_params_file
29
- end
30
-
31
- def summarize
32
- Lono::Inspector::Summary.new(template_name, @options).run
33
- end
34
-
35
- def show_params_file
36
- path = "config/params/base/#{template_name}.txt"
37
- puts "Here are contents of the params #{path.color(:green)} file:"
38
- puts IO.read("#{Lono.root}/#{path}")
39
- end
40
-
41
- def json?(text)
42
- JSON.load(text)
43
- true # if reach here than it's just
44
- rescue JSON::ParserError
45
- false # not json
46
- end
47
-
48
- def download_template
49
- template = open(@source).read
50
-
51
- result = if json?(template)
52
- # abusing YAML.dump(YAML.load()) to convert json to yaml
53
- YAML.dump(YAML.load(template))
54
- else
55
- template # template is already in YAML format
56
- end
57
-
58
- folder = File.dirname(template_path)
59
- FileUtils.mkdir_p(folder) unless File.exist?(folder)
60
- IO.write(template_path, result)
61
- end
62
-
63
- # Add template definition to app/definitions/base.rb.
64
- def add_template_definition
65
- path = "#{Lono.config.definitions_path}/base.rb"
66
- lines = File.exist?(path) ? IO.readlines(path) : []
67
- new_template_definition = %Q|template "#{template_name}"|
68
- unless lines.detect { |l| l.include?(new_template_definition) }
69
- lines << ["\n", new_template_definition]
70
- result = lines.join('')
71
- IO.write(path, result)
72
- end
73
- path
74
- end
75
-
76
- # Creates starter params/base/[stack-name].txt file
77
- def create_params
78
- template = YAML.load_file(template_path)
79
-
80
- result = []
81
- required_parameters.each do |name, attributes|
82
- result << "#{name}="
83
- end
84
- optional_parameters.each do |name, attributes|
85
- key = "#{name}=".ljust(20, ' ')
86
- result << "##{key} # optional"
87
- end
88
- content = result.join("\n") + "\n"
89
-
90
- folder = File.dirname(params_path)
91
- FileUtils.mkdir_p(folder) unless File.exist?(folder)
92
- IO.write(params_path, content) unless File.exist?(params_path)
93
- end
94
-
95
- def params_path
96
- "#{Lono.config.params_path}/base/#{template_name}.txt"
97
- end
98
-
99
-
100
- def template_path
101
- "#{Lono.config.templates_path}/#{template_name}.#{@format}"
102
- end
103
-
104
- def template_name
105
- return @options[:name] if @options[:name]
106
- # Else infer name from the original source.
107
- name = File.basename(@source, ".*")
108
- @options[:casing] == "camelcase" ? name.camelize : name.underscore.dasherize
109
- end
110
-
111
- private
112
- def required_parameters
113
- parameters.reject { |logical_id, p| p["Default"] }
114
- end
115
-
116
- def optional_parameters
117
- parameters.select { |logical_id, p| p["Default"] }
118
- end
119
-
120
- def parameters
121
- template_data["Parameters"] || []
122
- end
123
-
124
- def template_data
125
- return @template_data if @template_data
126
- template_path = "#{Lono.config.templates_path}/#{template_name}.#{@format}"
127
- @template_data = YAML.load(IO.read(template_path))
128
- end
129
-
130
- # removes the ./ at the beginning if it's there in the path
131
- def pretty_path(path)
132
- path[0..1] == './' ? path[2..-1] : path
133
- end
134
- end
@@ -1,35 +0,0 @@
1
- module Lono::New::Message
2
- private
3
- def welcome_message
4
- <<-EOL
5
- #{"="*64}
6
- Congrats 🎉 You have successfully created a lono project.
7
-
8
- Cd into your project and check things out:
9
-
10
- cd #{project_name}
11
-
12
- #{template_specific_message}
13
- To re-generate your templates without launching a stack, you can run:
14
-
15
- lono generate
16
-
17
- The generated CloudFormation templates are in the output/templates folder.
18
- The generated stack parameters are in the output/params folder.
19
-
20
- More info: http://lono.cloud/
21
- EOL
22
- end
23
-
24
- def template_specific_message
25
- starter_projects = File.expand_path("../../starter_projects", File.dirname(__FILE__))
26
- welcome_path = "#{starter_projects}/#{ENV['TEMPLATE']}/welcome.txt"
27
- puts "welcome_path #{welcome_path.inspect}"
28
-
29
- # default to the skeleton welcome message
30
- unless File.exist?(welcome_path)
31
- welcome_path = "#{starter_projects}/skeleton/welcome.txt"
32
- end
33
- IO.read(welcome_path)
34
- end
35
- end
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'lono'
@@ -1,118 +0,0 @@
1
- # Autoscaling Lono Example
2
-
3
- ## Usage
4
-
5
- Create a new project.
6
-
7
- ```
8
- TEMPLATE=autoscaling lono new autoscaling
9
- cd autoscaling
10
- ```
11
-
12
- Edit `config/params/base/autoscaling.txt` with your desired parameters. Here are the current contents of `config/params/base/autoscaling.txt`:
13
-
14
- ```sh
15
- VpcId=
16
- Subnets=
17
- OperatorEMail=
18
- KeyName=
19
- #InstanceType= # optional
20
- #SSHLocation= # optional
21
- ```
22
-
23
-
24
- Then launch the stack.
25
-
26
- ```sh
27
- lono cfn create autoscaling
28
- ```
29
-
30
- ## How This Example Was Originally Built
31
-
32
- First, generate a skeleton starter lono project.
33
-
34
- ```sh
35
- lono new autoscaling
36
- ```
37
-
38
- Then import a standard CloudFormation template into lono. The `--name` option is used to name the template `autoscaling`.
39
-
40
- ```
41
- $ lono import https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/AutoScalingMultiAZWithNotifications.template --name autoscaling
42
- => Imported CloudFormation template and lono-fied it.
43
- Template definition added to app/definitions/base.rb
44
- Params file created to config/params/base/autoscaling.txt
45
- Template downloaded to app/templates/autoscaling.yml
46
- => CloudFormation Template Summary:
47
- Parameters:
48
- Required:
49
- VpcId (AWS::EC2::VPC::Id)
50
- Subnets (List<AWS::EC2::Subnet::Id>)
51
- OperatorEMail (String)
52
- KeyName (AWS::EC2::KeyPair::KeyName)
53
- Optional:
54
- InstanceType (String) Default: t2.small
55
- SSHLocation (String) Default: 0.0.0.0/0
56
- Resources:
57
- 2 AWS::AutoScaling::ScalingPolicy
58
- 2 AWS::CloudWatch::Alarm
59
- 1 AWS::AutoScaling::LaunchConfiguration
60
- 1 AWS::ElasticLoadBalancingV2::LoadBalancer
61
- 1 AWS::ElasticLoadBalancingV2::Listener
62
- 1 AWS::ElasticLoadBalancingV2::TargetGroup
63
- 1 AWS::SNS::Topic
64
- 1 AWS::EC2::SecurityGroup
65
- 1 AWS::AutoScaling::AutoScalingGroup
66
- 9 Total
67
- Here are contents of the params config/params/base/autoscaling.txt file:
68
- VpcId=
69
- Subnets=
70
- OperatorEMail=
71
- KeyName=
72
- #InstanceType= # optional
73
- #SSHLocation= # optional
74
- $
75
- ```
76
-
77
- The template was imported from [CloudFormation Auto Scaling Samples](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/sample-templates-services-us-west-2.html#w2ab2c23c48c13b7).
78
-
79
- A starter `config/params/base/autoscaling.txt` was generated with required parameters emptied and optional parameters commented out. Fill in the required parameters.
80
-
81
- ### Filling in the Parameters
82
-
83
- You can use the following commands to grab the default VPC and a subnet, and set the values needed for the parameters:
84
-
85
- ```
86
- VPC=$(aws ec2 describe-vpcs | jq -r '.Vpcs[] | select(.IsDefault == true) | .VpcId')
87
- SUBNETS=$(aws ec2 describe-subnets | jq -r '.Subnets[].SubnetId' | tr -s '\n' ',' | sed 's/,*$//g')
88
- EMAIL=email@domain.com
89
- KEY_NAME=default
90
- ```
91
-
92
- Now update the required parameters:
93
-
94
- ```
95
- sed "s/VpcId=/VpcId=$VPC/; s/Subnets=/Subnets=$SUBNETS/; s/OperatorEMail=/OperatorEMail=$EMAIL/; s/KeyName=/KeyName=$KEY_NAME/;" config/params/base/autoscaling.txt > config/params/base/autoscaling.txt.1
96
- mv config/params/base/autoscaling.txt{.1,}
97
- ```
98
-
99
- Now launch the stack:
100
-
101
- ```
102
- lono cfn create autoscaling
103
- ```
104
-
105
- ## Commands Summarized
106
-
107
- ```sh
108
- lono new autoscaling
109
- cd autoscaling
110
- lono import https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/AutoScalingMultiAZWithNotifications.template --name autoscaling
111
- VPC=$(aws ec2 describe-vpcs | jq -r '.Vpcs[] | select(.IsDefault == true) | .VpcId')
112
- SUBNETS=$(aws ec2 describe-subnets --filters Name=vpc-id,Values=$VPC | jq -r '.Subnets[].SubnetId' | tr -s '\n' ',' | sed 's/,*$//g')
113
- EMAIL=email@domain.com
114
- KEY_NAME=default
115
- sed "s/VpcId=/VpcId=$VPC/; s/Subnets=/Subnets=$SUBNETS/; s/OperatorEMail=/OperatorEMail=$EMAIL/; s/KeyName=/KeyName=$KEY_NAME/;" config/params/base/autoscaling.txt > config/params/base/autoscaling.txt.1
116
- mv config/params/base/autoscaling.txt{.1,}
117
- lono cfn create autoscaling --template autoscaling
118
- ```