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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0cbcfa87ee5f1282166f6d878e37bf3f69b8f2facbad9774ed254d72d90f75e
4
- data.tar.gz: f63bfd75b1892b6a7eacade99308cbf164afc026795d636daab59974ea0fe416
3
+ metadata.gz: eab7933de970a48215d89f351912ab01931bc0fd08083d273cb3dc660795d4f3
4
+ data.tar.gz: 99dd7038597bece84bc118ab0dd7272a59ab5ecc6735024e3b9393dd8e453072
5
5
  SHA512:
6
- metadata.gz: ba2ad72fb843067693c95df59783e06a6e5943777fac3ed65ea96ca5d04a3f4ccb76e834cc5490e5edb7f2d967a3d0f7dbd9ae278d55f33f7b9678909e5487e3
7
- data.tar.gz: 00b0fbeb10085941bdd18ad53f5c46f0e5f45c9f1d946bc3f1bd1822d30824e86b269ce4c92e8e8114384a2cbd13cd9e177740000f971d48c0ef40f17257f460
6
+ metadata.gz: 6845fbe057aa1e6b2ba479b38e8be9121a8588b11ae24e64e06c07334a62881aa5763158f6453e051e81f3402a31763abecf2f3caf7f77aacb2aa95f69e4fc13
7
+ data.tar.gz: 29bfb1dff44778cd35a78b91a0b705e9a57ec5c6f8f587fcc2022a2732379d32e24aa2f8f03e13256171d649f92928d7dbac30f1db118ebfe53528ca784bf43d
@@ -0,0 +1,6 @@
1
+ # CodeBuild Cheatsheet
2
+
3
+ Command to kick off build:
4
+
5
+ aws codebuild start-build --project-name lono-acceptance # master branch
6
+ aws codebuild start-build --project-name lono-acceptance --source-version another-branch
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+
3
+ set -exu
4
+
5
+ # https://unix.stackexchange.com/questions/1496/why-doesnt-my-bash-script-recognize-aliases
6
+ shopt -s expand_aliases
7
+ alias bolt="$(pwd)/exe/bolt"
8
+
9
+ bundle install --without development test
10
+
11
+ rm -rf infra
12
+
13
+ bolt new infra
14
+ # Very simply template with just a security group
15
+ cp .codebuild/demo.rb infra/blueprints/demo/app/templates/demo.rb
16
+ cd infra
17
+
18
+ # Rewrite the Gemfile to use the local bolt gem for testing
19
+ cat << EOF > Gemfile
20
+ source "https://rubygems.org"
21
+ gem "bolt", path: "$CODEBUILD_SRC_DIR", submodules: true
22
+ EOF
23
+
24
+ bundle # install bolt gem in the infra project
25
+
26
+ STACK_NAME="demo-$(date +%Y%m%d%H%M%S)"
27
+
28
+ bolt cfn deploy $STACK_NAME --blueprint demo
29
+ bolt cfn status $STACK_NAME
30
+ bolt cfn delete $STACK_NAME --sure
@@ -0,0 +1,21 @@
1
+ version: 0.2
2
+
3
+ phases:
4
+ pre_build:
5
+ commands:
6
+ - uname -a
7
+ - pwd
8
+ - ls
9
+ - env
10
+ - ls /etc/*release*
11
+ - cat /etc/*release*
12
+ - whoami
13
+ build:
14
+ commands:
15
+ - echo Build started on `date`
16
+ - echo Building project...
17
+ - uptime
18
+ - .codebuild/acceptance.sh
19
+ artifacts:
20
+ files:
21
+ - result.txt
@@ -0,0 +1,38 @@
1
+ # Acceptance Level Stack
2
+ aws_template_format_version "2010-09-09"
3
+ description "Demo stack"
4
+
5
+ parameter(:instance_type, "t3.micro")
6
+
7
+ mapping(:ami_map,
8
+ "ap-northeast-1": { ami: "ami-0f9ae750e8274075b" },
9
+ "ap-northeast-2": { ami: "ami-047f7b46bd6dd5d84" },
10
+ "ap-south-1": { ami: "ami-0889b8a448de4fc44" },
11
+ "ap-southeast-1": { ami: "ami-0b419c3a4b01d1859" },
12
+ "ap-southeast-2": { ami: "ami-04481c741a0311bbb" },
13
+ "ca-central-1": { ami: "ami-03338e1f67dae0168" },
14
+ "eu-central-1": { ami: "ami-09def150731bdbcc2" },
15
+ "eu-north-1": { ami: "ami-d16fe6af" },
16
+ "eu-west-1": { ami: "ami-07683a44e80cd32c5" },
17
+ "eu-west-2": { ami: "ami-09ead922c1dad67e4" },
18
+ "eu-west-3": { ami: "ami-0451ae4fd8dd178f7" },
19
+ "sa-east-1": { ami: "ami-0669a96e355eac82f" },
20
+ "us-east-1": { ami: "ami-0de53d8956e8dcf80" },
21
+ "us-east-2": { ami: "ami-02bcbb802e03574ba" },
22
+ "us-west-1": { ami: "ami-0019ef04ac50be30f" },
23
+ "us-west-2": { ami: "ami-061392db613a6357b" }
24
+ )
25
+
26
+ # Comment out instance to save costs
27
+ # resource(:instance, "AWS::EC2::Instance",
28
+ # instance_type: ref(:instance_type),
29
+ # image_id: find_in_map(:ami_map, ref("AWS::Region"), :ami),
30
+ # security_group_ids: [get_att("security_group.group_id")],
31
+ # user_data: base64(user_data("bootstrap.sh"))
32
+ # )
33
+ resource(:security_group, "AWS::EC2::SecurityGroup",
34
+ group_description: "demo security group",
35
+ )
36
+
37
+ # output(:instance)
38
+ output(:security_group, get_att("security_group.group_id"))
@@ -0,0 +1,12 @@
1
+ # For methods, refer to the properties of the CloudFormation CodeBuild::Project https://amzn.to/2UTeNlr
2
+ # For convenience methods, refer to the source https://github.com/tongueroo/codebuild/blob/master/lib/codebuild/dsl/project.rb
3
+
4
+ github_url("https://github.com/boltopspro/bolt.git")
5
+ linux_image("aws/codebuild/ruby:2.5.3-1.7.0")
6
+
7
+ # Uncomment to enable github webhook, the GitHub oauth token needs admin:repo_hook permissions
8
+ # Refer to https://github.com/tongueroo/codebuild/blob/master/readme/github_oauth.md
9
+ triggers(webhook: true)
10
+
11
+ # Shorthand to enable all local cache modes
12
+ # local_cache(true)
@@ -0,0 +1 @@
1
+ iam_policy("logs", "ssm", "cloudformation", "ec2")
data/.gitignore CHANGED
@@ -19,3 +19,5 @@ spec/reports
19
19
  test/tmp
20
20
  test/version_tmp
21
21
  tmp
22
+
23
+ /infra
@@ -1,3 +1,6 @@
1
- [submodule "vendor/plissken"]
2
- path = vendor/plissken
3
- url = https://github.com/tongueroo/plissken.git
1
+ [submodule "vendor/cfn-status"]
2
+ path = vendor/cfn-status
3
+ url = https://github.com/tongueroo/cfn-status
4
+ [submodule "vendor/cfn_camelizer"]
5
+ path = vendor/cfn_camelizer
6
+ url = https://github.com/tongueroo/cfn_camelizer
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 2.0.1
@@ -3,6 +3,16 @@
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
+ ## [5.0.1]
7
+ - Introduce lono DSL and set as default mode
8
+ - Introduce blueprints concept
9
+ - Introduce lono cfn deploy command
10
+ - Auto-create lono managed s3 bucket
11
+ - Zeitwerk autoloader
12
+ - Restructure project structure
13
+ - Remove aws\_profiles settings.yml in favor of aws_profile
14
+ - lono upgrade v4to5 command
15
+
6
16
  ## [4.2.7]
7
17
  - retain tag values on cfn update operations
8
18
 
data/Gemfile CHANGED
@@ -4,4 +4,3 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  gem "codeclimate-test-reporter", group: :test, require: nil
7
-
@@ -1,22 +1 @@
1
- Copyright (c) 2018 Tung Nguyen
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ https://www.boltops.com/boltops-community-license
data/README.md CHANGED
@@ -4,74 +4,75 @@
4
4
 
5
5
  # Lono
6
6
 
7
- [![Gem Version](https://badge.fury.io/rb/lono.png)](http://badge.fury.io/rb/lono)
8
- [![CircleCI](https://circleci.com/gh/tongueroo/lono.svg?style=svg)](https://circleci.com/gh/tongueroo/lono)
9
- [![Code Climate][3]][4]
10
- [![Dependency Status](https://gemnasium.com/tongueroo/lono.png)](https://gemnasium.com/tongueroo/lono)
11
- [![Coverage Status](https://coveralls.io/repos/tongueroo/lono/badge.png)](https://coveralls.io/r/tongueroo/lono)
12
- [![Join the chat at https://gitter.im/tongueroo/lono](https://badges.gitter.im/tongueroo/lono.svg)](https://gitter.im/tongueroo/lono?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
+ ![CodeBuild](https://codebuild.us-west-2.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiaHF3Y2pqSVBlZ0JMdXhPL010bTI2cVd6SkpHQWlLRkJ5SHlCcDFueUtHVFNCVFZyWEVZd01yWDZ1VjZCRjNVQ1F4d2JlTlJOWDRtU3R3NkJzVkJKSHJ3PSIsIml2UGFyYW1ldGVyU3BlYyI6IkZIRVZwM00rQzQxcDJWaVMiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master)
13
8
  [![Support](https://img.shields.io/badge/get-support-blue.svg)](https://boltops.com?utm_source=badge&utm_medium=badge&utm_campaign=lono)
14
9
 
15
- [3]: https://codeclimate.com/repos/51d7f1407e00a4042c010ab4/badges/5273fe6cdb5a13e58554/gpa.png
16
- [4]: https://codeclimate.com/repos/51d7f1407e00a4042c010ab4/feed
10
+ Lono is a powerful CloudFormation framework. Lono handles the entire CloudFormation lifecycle. It builds, manages and deploys CloudFormation templates.
17
11
 
18
- Lono is a tool to help you manage your CloudFormation templates. Lono handles the entire CloudFormation lifecyle. It helps you craft the templates and then provision the infrastructure.
19
-
20
- * Lono generates CloudFormation templates based on ERB ruby templates in `yaml` format.
12
+ * Lono generates CloudFormation templates based on a [DSL](http://lono.cloud/docs/dsl/).
21
13
  * Lono takes simple env-like files and generates the CloudFormation parameter files.
22
14
  * Lono provides a simple CLI interface to launch the CloudFormation stacks.
23
15
 
24
16
  See [lono.cloud](http://lono.cloud) for full lono documentation.
25
17
 
26
- ## Important
18
+ ## Upgrading
27
19
 
28
- If you are on version 3, you can run `lono upgrade v3to4` within your project to upgrade it to version 4. Refer to the [CHANGELOG](CHANGELOG.md).
20
+ If you are on version 4.2 and upgrade to 5.0. You can run `lono upgrade v4to5` within your project to upgrade it to version 5.0. Refer to the [Upgrading Guide](http://lono.cloud/docs/extras/upgrading/).
29
21
 
30
- If you are on version 4.0 or 4.1 and need to uppgrade to 4.2. You can run `lono upgrade v4to4_2` within your project to upgrade it to version 4.2. Refer to the [CHANGELOG](CHANGELOG.md).
22
+ ## Quick Usage
31
23
 
32
- ## Blog Posts
24
+ It only takes a couple of commands to start using lono.
33
25
 
34
- These blog posts also cover lono:
26
+ gem install lono
27
+ lono new infra
28
+ cd infra
29
+ lono cfn deploy demo
35
30
 
36
- * [Why Generate CloudFormation Templates with Lono](https://medium.com/boltops/why-generate-cloudformation-templates-with-lono-65b8ea5eb87d)
37
- * [Generating CloudFormation Templates with Lono](https://medium.com/boltops/generating-cloudformation-templates-with-lono-4709afa1299b)
38
- * [AutoScaling CloudFormation Template with Lono](https://medium.com/boltops/autoscaling-cloudformation-template-with-lono-3dc520480c5f)
39
- * [CloudFormation Tools: lono, lono-params and lono cfn Together](https://medium.com/boltops/cloudformation-tools-lono-lono-params-and-lono-cfn-play-together-620af51e616)
40
- * [AWS CloudFormation dry-run with lono cfn preview](https://medium.com/boltops/aws-cloudformation-dry-run-with-lono-cfn-plan-2a1e0f80d13c)
31
+ ![Lono flowchart](http://lono.cloud/img/tutorial/lono-flowchart.png "Lono flowchart")
41
32
 
42
- ## Quick Usage
33
+ ## DSL
43
34
 
44
- It only takes a couple of commands to start using lono.
35
+ Here's an example of what the Lono CloudFormation DSL looks like:
36
+
37
+ ```ruby
38
+ description "Demo stack"
39
+
40
+ parameter(:instance_type, "t3.micro")
41
+
42
+ mapping(:ami_map,
43
+ "us-east-1": { ami: "ami-0de53d8956e8dcf80" },
44
+ "us-west-2": { ami: "ami-061392db613a6357b" }
45
+ )
46
+
47
+ resource(:instance, "AWS::EC2::Instance",
48
+ instance_type: ref(:instance_type),
49
+ image_id: find_in_map(:ami_map, ref("AWS::Region"), :ami),
50
+ security_group_ids: [get_att("security_group.group_id")],
51
+ user_data: base64(user_data("bootstrap.sh"))
52
+ )
53
+ resource(:security_group, "AWS::EC2::SecurityGroup",
54
+ group_description: "demo security group",
55
+ )
45
56
 
46
- ```sh
47
- gem install lono
48
- lono new infra
49
- cd infra
50
- lono import https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/EC2InstanceWithSecurityGroupSample.template --name ec2
51
- # update the generated params file
52
- lono cfn create ec2
57
+ output(:instance)
58
+ output(:security_group, get_att("security_group.group_id"))
53
59
  ```
54
- ![Lono flowchart](http://tongueroo.com/images/github-readmes/lono-flowchart.png "Lono flowchart")
55
60
 
56
61
  ### Lono Cfn Lifecycle Commands
57
62
 
58
- Lono provides a `lono cfn` lifecycle command that allows you to launch stacks quickly. The `lono cfn` tool automatically runs `lono generate` internally and then launches the CloudFormation stack all in one command. If you are in a lono project and have a `my-stack` lono template definition. To create a stack you can simply run:
63
+ Lono provides a `lono cfn` lifecycle command that allows you to launch stacks quickly. The `lono cfn` tool automatically runs `lono generate` internally and then launches the CloudFormation stack all in one command. If you are in a lono project and have a `demo` lono blueprint. To create a stack you can simply run:
59
64
 
60
- ```
61
- $ lono cfn create my-stack
62
- ```
65
+ $ lono cfn deploy demo
63
66
 
64
- The above command will generate files to `output/templates/my-stack.json` and `output/params/my-stack.txt` and use them to create a CloudFormation stack. Here are some more examples of cfn commands:
67
+ The above command will generate files to `output/infra/templates/demo.yml` and `output/infra/params/demo.txt` and use them to create a CloudFormation stack. Here are some more examples of cfn commands:
65
68
 
66
- ```
67
- $ lono cfn create mystack-$(date +%Y%m%d%H%M%S) --template mystack --params mystack
68
- $ lono cfn create mystack-$(date +%Y%m%d%H%M%S) # shorthand if template and params file matches.
69
- $ lono cfn diff mystack-1493859659
70
- $ lono cfn preview mystack-1493859659
71
- $ lono cfn update mystack-1493859659
72
- $ lono cfn delete mystack-1493859659
73
- $ lono cfn create -h # getting help
74
- ```
69
+ lono cfn deploy demo # shorthand if blueprint, template and params file matches.
70
+ lono cfn deploy demo-$(date +%Y%m%d%H%M%S) --blueprint demo --template demo --param demo
71
+ lono cfn diff demo-1493859659
72
+ lono cfn preview demo-1493859659
73
+ lono cfn update demo-1493859659
74
+ lono cfn delete demo-1493859659
75
+ lono cfn deploy -h # getting help
75
76
 
76
77
  See [lono.cloud](http://lono.cloud) for full lono documentation.
77
78
 
@@ -82,13 +83,3 @@ See [lono.cloud](http://lono.cloud) for full lono documentation.
82
83
  3. Commit your changes (`git commit -am 'Add some feature'`)
83
84
  4. Push to the branch (`git push origin my-new-feature`)
84
85
  5. Create new Pull Request
85
-
86
- ## Developing
87
-
88
- There is a submodule in this project, so when you check out remember to sync the submodule.
89
-
90
- ```bash
91
- $ git clone git@github.com:yourfork/lono.git
92
- $ git submodule sync
93
- $ git submodule update --init
94
- ```
@@ -1,39 +1,32 @@
1
+ $stdout.sync = true unless ENV["LONO_STDOUT_SYNC"] == "0"
2
+
3
+ require 'active_support/core_ext/hash'
1
4
  require 'active_support/core_ext/string'
2
5
  require 'fileutils'
3
6
  require 'json'
4
7
  require 'memoist'
8
+ require 'plissken'
5
9
  require 'rainbow/ext/string'
6
10
  require 'render_me_pretty'
7
11
  require 'yaml'
8
12
 
9
- # vendor because need https://github.com/futurechimp/plissken/pull/6 to be merged
10
- $:.unshift(File.expand_path("../../vendor/plissken/lib", __FILE__))
11
- require "plissken"
13
+ gem_root = File.dirname(__dir__)
14
+ $:.unshift("#{gem_root}/lib")
15
+ $:.unshift("#{gem_root}/vendor/cfn-status/lib")
16
+ require "cfn/status"
17
+ $:.unshift("#{gem_root}/vendor/cfn_camelizer/lib")
18
+ require "cfn_camelizer"
12
19
 
13
- $:.unshift(File.expand_path('../', __FILE__))
14
- module Lono
15
- autoload :Cfn, 'lono/cfn'
16
- autoload :Clean, 'lono/clean'
17
- autoload :CLI, 'lono/cli'
18
- autoload :Command, 'lono/command'
19
- autoload :Completer, 'lono/completer'
20
- autoload :Completion, 'lono/completion'
21
- autoload :Core, 'lono/core'
22
- autoload :Env, 'lono/env'
23
- autoload :FileUploader, 'lono/file_uploader'
24
- autoload :Help, 'lono/help'
25
- autoload :Importer, 'lono/importer'
26
- autoload :Inspector, 'lono/inspector'
27
- autoload :New, 'lono/new'
28
- autoload :Param, 'lono/param'
29
- autoload :ProjectChecker, 'lono/project_checker'
30
- autoload :Script, 'lono/script'
31
- autoload :Sequence, 'lono/sequence'
32
- autoload :Setting, 'lono/setting'
33
- autoload :Template, 'lono/template'
34
- autoload :Upgrade, 'lono/upgrade'
35
- autoload :UserData, 'lono/user_data'
36
- autoload :VERSION, 'lono/version'
20
+ require "lono/autoloader"
21
+ Lono::Autoloader.setup
37
22
 
23
+ module Lono
38
24
  extend Core
39
25
  end
26
+
27
+ Lono.set_aws_profile!
28
+
29
+ begin
30
+ require "lono-pro" # optional
31
+ rescue LoadError
32
+ end
@@ -0,0 +1,5 @@
1
+ # Unsure why but zeitwerk is not autovifiying this as a module
2
+ # Adding this fixes the issue.
3
+ # Also using bundle exec in front works. Ran into this with jets also and Jets just bundle exec witihin the project.
4
+ module Lono::AppFile
5
+ end
@@ -0,0 +1,19 @@
1
+ # Naming AppFile instead of File so we dont to use ::File for normal regular File class
2
+ module Lono::AppFile
3
+ class Base
4
+ include Lono::Blueprint::Root
5
+ extend Memoist
6
+
7
+ def initialize(blueprint, options = {})
8
+ @blueprint, @options = blueprint, options
9
+ @template = @options[:template] || @blueprint
10
+ Lono::ProjectChecker.check
11
+ set_blueprint_root(@blueprint)
12
+ Lono::ProjectChecker.empty_templates
13
+ initialize_variables
14
+ end
15
+
16
+ def initialize_variables
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,78 @@
1
+ module Lono::AppFile
2
+ class Build < Base
3
+ def initialize_variables
4
+ @output_files_path = "#{Lono.config.output_path}/#{@blueprint}/files"
5
+ end
6
+
7
+ def run
8
+ return unless detect_files?
9
+
10
+ puts "Building app/files for blueprint #{@blueprint}"
11
+ build_all
12
+ end
13
+
14
+ def build_all
15
+ clean_output
16
+ copy_to_output
17
+ Registry.items.each do |item|
18
+ if item.directory?
19
+ zip_directory(item)
20
+ elsif item.file?
21
+ zip_file(item)
22
+ else
23
+ puts "WARN: #{item.path} does not exist. Double check that the path is correct in the s3_key call.".color(:yellow)
24
+ end
25
+ end
26
+ end
27
+
28
+ def zip_file(item)
29
+ path = item.path
30
+ zip_file = item.zip_file_name
31
+
32
+ puts "Zipping file and generating md5 named file from: #{path}"
33
+ command = "cd #{File.dirname(path)} && zip -q #{zip_file} #{File.basename(path)}" # create zipfile at same level of file
34
+ zip(command)
35
+ end
36
+
37
+ def zip_directory(item)
38
+ path = item.path
39
+ zip_file = item.zip_file_name
40
+
41
+ puts "Zipping folder and generating md5 named file from: #{path}"
42
+ command = "cd #{path} && zip --symlinks -rq #{zip_file} ." # create zipfile witih directory
43
+ zip(command)
44
+ FileUtils.mv("#{path}/#{zip_file}", "#{File.dirname(path)}/#{zip_file}") # move zip back to the parent directory
45
+ end
46
+
47
+ def zip(command)
48
+ # puts "=> #{command}".color(:green) # uncomment to debug
49
+ `#{command}`
50
+ unless $?.success?
51
+ puts "ERROR: Fail to run #{command}".color(:red)
52
+ puts "Maybe zip is not installed or path is incorrect?"
53
+ exit 1
54
+ end
55
+ end
56
+
57
+ def clean_output
58
+ FileUtils.rm_rf(@output_files_path)
59
+ end
60
+
61
+ def copy_to_output
62
+ src = "#{Lono.blueprint_root}/app/files"
63
+ dest = @output_files_path
64
+ FileUtils.mkdir_p(File.dirname(dest))
65
+ FileUtils.cp_r(src, dest)
66
+ end
67
+
68
+ def detect_files?
69
+ app_files = Dir["#{Lono.blueprint_root}/app/files/*"]
70
+ if app_files.empty?
71
+ false
72
+ else
73
+ puts "Detected app/files for blueprint #{@blueprint}"
74
+ true
75
+ end
76
+ end
77
+ end
78
+ end