lono 7.4.11 → 8.0.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (452) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/README.md +5 -15
  3. data/.cody/acceptance/bin/build.sh +52 -0
  4. data/.cody/acceptance/buildspec.yml +10 -0
  5. data/.cody/acceptance/project.rb +6 -0
  6. data/.cody/{role.rb → acceptance/role.rb} +0 -0
  7. data/.cody/shared/script/install/lono.sh +40 -0
  8. data/.cody/shared/script/install.sh +5 -0
  9. data/CHANGELOG.md +33 -5
  10. data/CONTRIBUTING.md +2 -2
  11. data/Gemfile +5 -1
  12. data/LICENSE.txt +201 -1
  13. data/README.md +6 -5
  14. data/lib/lono/api/client.rb +3 -2
  15. data/lib/lono/app/inits.rb +13 -0
  16. data/lib/lono/app.rb +71 -0
  17. data/lib/lono/app_file/base.rb +1 -1
  18. data/lib/lono/app_file/build/lambda_layer/ruby_packager.rb +9 -9
  19. data/lib/lono/app_file/build/lambda_layer.rb +3 -3
  20. data/lib/lono/app_file/build.rb +9 -14
  21. data/lib/lono/app_file/registry/item.rb +4 -4
  22. data/lib/lono/app_file/upload.rb +1 -1
  23. data/lib/lono/autoloader.rb +2 -2
  24. data/lib/lono/aws_services/helper.rb +43 -6
  25. data/lib/lono/aws_services.rb +37 -6
  26. data/lib/lono/blueprint.rb +18 -9
  27. data/lib/lono/booter.rb +28 -0
  28. data/lib/lono/{template → builder}/context/helpers.rb +1 -1
  29. data/lib/lono/{template → builder}/context/loader/load_files.rb +5 -6
  30. data/lib/lono/builder/context/loader.rb +35 -0
  31. data/lib/lono/builder/context/params.rb +7 -0
  32. data/lib/lono/{template → builder}/context/ssm_fetcher.rb +1 -1
  33. data/lib/lono/{template → builder}/context.rb +5 -9
  34. data/lib/lono/{param/generator.rb → builder/param.rb} +21 -22
  35. data/lib/lono/builder/template/aws_service.rb +15 -0
  36. data/lib/lono/builder/template/bashify.rb +43 -0
  37. data/lib/lono/{template → builder/template}/configset_injector.rb +4 -4
  38. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/fn.rb +2 -2
  39. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/core_helper.rb +1 -1
  40. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/ec2_helper.rb +1 -1
  41. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/file_helper.rb +8 -12
  42. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/s3_helper.rb +2 -2
  43. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/stack_helper.rb +11 -8
  44. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/tags_helper.rb +1 -1
  45. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers.rb +2 -2
  46. data/lib/lono/builder/template/dsl/evaluator/section/base.rb +23 -0
  47. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/condition.rb +1 -1
  48. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/mapping.rb +1 -1
  49. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/methods.rb +7 -7
  50. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/output.rb +1 -1
  51. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/parameter.rb +1 -1
  52. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/resource/property_mover.rb +1 -1
  53. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/resource.rb +1 -1
  54. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/section.rb +1 -1
  55. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/squeezer.rb +1 -1
  56. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/stringify.rb +1 -1
  57. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax/extend_with.rb +1 -1
  58. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax/parameter_group.rb +1 -1
  59. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax.rb +3 -3
  60. data/lib/lono/builder/template/dsl/evaluator.rb +45 -0
  61. data/lib/lono/{template/strategy → builder/template}/dsl/finalizer/parameter_groups.rb +2 -2
  62. data/lib/lono/{template/strategy → builder/template}/dsl/finalizer.rb +1 -1
  63. data/lib/lono/builder/template/dsl.rb +14 -0
  64. data/lib/lono/{template → builder/template}/evaluate.rb +18 -6
  65. data/lib/lono/builder/template/helpers.rb +149 -0
  66. data/lib/lono/{output/template.rb → builder/template/output.rb} +14 -7
  67. data/lib/lono/{template → builder/template}/post_processor.rb +4 -4
  68. data/lib/lono/{template → builder/template}/upload.rb +3 -5
  69. data/lib/lono/builder/template.rb +55 -0
  70. data/lib/lono/bundler/cli/base.rb +10 -0
  71. data/lib/lono/bundler/cli/bundle.rb +44 -0
  72. data/lib/lono/bundler/cli/clean.rb +27 -0
  73. data/lib/lono/bundler/cli/help/bundle.md +3 -0
  74. data/lib/lono/bundler/cli/help.rb +11 -0
  75. data/lib/lono/bundler/cli.rb +7 -0
  76. data/lib/lono/bundler/component/concerns/local_concern.rb +10 -0
  77. data/lib/lono/bundler/component/concerns/notation_concern.rb +59 -0
  78. data/lib/lono/bundler/component/concerns/path_concern.rb +68 -0
  79. data/lib/lono/bundler/component/concerns/stack_concern.rb +60 -0
  80. data/lib/lono/bundler/component/fetcher/base.rb +27 -0
  81. data/lib/lono/bundler/component/fetcher/gcs.rb +69 -0
  82. data/lib/lono/bundler/component/fetcher/git.rb +69 -0
  83. data/lib/lono/bundler/component/fetcher/local.rb +15 -0
  84. data/lib/lono/bundler/component/fetcher/s3.rb +66 -0
  85. data/lib/lono/bundler/component/fetcher.rb +18 -0
  86. data/lib/lono/bundler/component/http/concern.rb +45 -0
  87. data/lib/lono/bundler/component/http/source.rb +19 -0
  88. data/lib/lono/bundler/component/org_repo.rb +65 -0
  89. data/lib/lono/bundler/component/props/extension.rb +19 -0
  90. data/lib/lono/bundler/component/props/typer.rb +41 -0
  91. data/lib/lono/bundler/component/props.rb +122 -0
  92. data/lib/lono/bundler/component/registry.rb +136 -0
  93. data/lib/lono/bundler/component.rb +52 -0
  94. data/lib/lono/bundler/config.rb +18 -0
  95. data/lib/lono/bundler/dsl/syntax.rb +46 -0
  96. data/lib/lono/bundler/dsl.rb +21 -0
  97. data/lib/lono/bundler/exporter/base.rb +6 -0
  98. data/lib/lono/bundler/exporter/copy.rb +22 -0
  99. data/lib/lono/bundler/exporter.rb +50 -0
  100. data/lib/lono/bundler/extract/tar.rb +34 -0
  101. data/lib/lono/bundler/extract/zip.rb +16 -0
  102. data/lib/lono/bundler/info.rb +39 -0
  103. data/lib/lono/bundler/list.rb +26 -0
  104. data/lib/lono/bundler/lockfile/version_comparer.rb +56 -0
  105. data/lib/lono/bundler/lockfile/yamler.rb +36 -0
  106. data/lib/lono/bundler/lockfile.rb +66 -0
  107. data/lib/lono/bundler/lonofile.rb +32 -0
  108. data/lib/lono/bundler/runner.rb +27 -0
  109. data/lib/lono/bundler/syncer.rb +70 -0
  110. data/lib/lono/bundler/util/git.rb +37 -0
  111. data/lib/lono/bundler/util/logging.rb +7 -0
  112. data/lib/lono/bundler/util/sure.rb +5 -0
  113. data/lib/lono/{bundle.rb → bundler.rb} +38 -4
  114. data/lib/lono/cfn/base.rb +9 -196
  115. data/lib/lono/cfn/cancel.rb +9 -26
  116. data/lib/lono/cfn/concerns/build.rb +10 -0
  117. data/lib/lono/cfn/concerns/template_output.rb +10 -0
  118. data/lib/lono/cfn/concerns.rb +43 -0
  119. data/lib/lono/cfn/delete.rb +8 -32
  120. data/lib/lono/cfn/deploy/base.rb +4 -0
  121. data/lib/lono/cfn/deploy/iam.rb +49 -0
  122. data/lib/lono/cfn/deploy/notification.rb +8 -0
  123. data/lib/lono/cfn/deploy/operable.rb +18 -0
  124. data/lib/lono/cfn/deploy/opts.rb +49 -0
  125. data/lib/lono/cfn/deploy/rollback.rb +46 -0
  126. data/lib/lono/cfn/deploy/tags.rb +18 -0
  127. data/lib/lono/cfn/deploy.rb +71 -5
  128. data/lib/lono/cfn/download.rb +5 -7
  129. data/lib/lono/cfn/output.rb +49 -0
  130. data/lib/lono/cfn/plan/base.rb +19 -0
  131. data/lib/lono/cfn/plan/changeset/base.rb +19 -0
  132. data/lib/lono/cfn/plan/changeset/notifications.rb +24 -0
  133. data/lib/lono/cfn/plan/changeset/outputs.rb +25 -0
  134. data/lib/lono/cfn/plan/changeset/resources.rb +48 -0
  135. data/lib/lono/cfn/plan/changeset/tags.rb +16 -0
  136. data/lib/lono/cfn/plan/changeset.rb +136 -0
  137. data/lib/lono/cfn/plan/concerns.rb +10 -0
  138. data/lib/lono/cfn/plan/delete.rb +16 -0
  139. data/lib/lono/cfn/plan/diff/base.rb +10 -0
  140. data/lib/lono/cfn/plan/diff/data.rb +52 -0
  141. data/lib/lono/cfn/plan/diff/file.rb +56 -0
  142. data/lib/lono/cfn/plan/new.rb +26 -0
  143. data/lib/lono/cfn/{preview → plan}/param.rb +26 -34
  144. data/lib/lono/cfn/plan/summary.rb +16 -0
  145. data/lib/lono/cfn/plan/template.rb +28 -0
  146. data/lib/lono/cfn/plan.rb +33 -0
  147. data/lib/lono/cfn/show.rb +30 -0
  148. data/lib/lono/cfn/status.rb +1 -1
  149. data/lib/lono/cli/abstract.rb +17 -0
  150. data/lib/lono/cli/base.rb +9 -0
  151. data/lib/lono/cli/build.rb +101 -0
  152. data/lib/lono/cli/bundle.rb +21 -0
  153. data/lib/lono/cli/cfn/opts.rb +59 -0
  154. data/lib/lono/cli/cfn.rb +19 -0
  155. data/lib/lono/cli/clean.rb +22 -0
  156. data/lib/lono/{code.rb → cli/code.rb} +2 -2
  157. data/lib/lono/{completion.rb → cli/completion.rb} +2 -2
  158. data/lib/lono/{help → cli/help}/blueprint/new.md +4 -4
  159. data/lib/lono/{help/generate.md → cli/help/build.md} +6 -6
  160. data/lib/lono/{help → cli/help}/cfn/cancel.md +0 -0
  161. data/lib/lono/cli/help/cfn/download.md +3 -0
  162. data/lib/lono/{help → cli/help}/cfn/preview.md +9 -8
  163. data/lib/lono/{help → cli/help}/cfn/status.md +0 -0
  164. data/lib/lono/cli/help/cfn.md +4 -0
  165. data/lib/lono/{help → cli/help}/code/convert.md +0 -0
  166. data/lib/lono/{help → cli/help}/code/import.md +2 -2
  167. data/lib/lono/{help → cli/help}/completion.md +3 -3
  168. data/lib/lono/{help → cli/help}/completion_script.md +0 -0
  169. data/lib/lono/{help → cli/help}/configsets.md +0 -0
  170. data/lib/lono/cli/help/down.md +13 -0
  171. data/lib/lono/cli/help/new/project.md +34 -0
  172. data/lib/lono/{help → cli/help}/param/generate.md +0 -0
  173. data/lib/lono/cli/help/param.md +6 -0
  174. data/lib/lono/{help → cli/help}/pro/blueprints.md +0 -0
  175. data/lib/lono/{help → cli/help}/pro/configsets.md +0 -0
  176. data/lib/lono/{help → cli/help}/script/build.md +0 -0
  177. data/lib/lono/{help → cli/help}/script/upload.md +0 -0
  178. data/lib/lono/{help → cli/help}/seed.md +2 -2
  179. data/lib/lono/cli/help/summary.md +33 -0
  180. data/lib/lono/{help → cli/help}/template/bashify.md +0 -0
  181. data/lib/lono/cli/help/template/generate.md +7 -0
  182. data/lib/lono/{help → cli/help}/template.md +0 -0
  183. data/lib/lono/cli/help/up.md +30 -0
  184. data/lib/lono/{help → cli/help}/user_data.md +3 -3
  185. data/lib/lono/cli/help.rb +56 -0
  186. data/lib/lono/cli/list.rb +28 -0
  187. data/lib/lono/cli/new/blueprint.rb +33 -0
  188. data/lib/lono/cli/new/concerns.rb +16 -0
  189. data/lib/lono/{configset/new.rb → cli/new/configset.rb} +2 -9
  190. data/lib/lono/{extension/new.rb → cli/new/extension.rb} +2 -10
  191. data/lib/lono/cli/new/helper.rb +32 -0
  192. data/lib/lono/cli/new/project.rb +77 -0
  193. data/lib/lono/cli/new/sequence.rb +51 -0
  194. data/lib/lono/cli/new/shim.rb +59 -0
  195. data/lib/lono/cli/new/test/blueprint.rb +23 -0
  196. data/lib/lono/cli/new/test/sequence.rb +10 -0
  197. data/lib/lono/cli/new/test.rb +8 -0
  198. data/lib/lono/cli/new.rb +31 -0
  199. data/lib/lono/{opts.rb → cli/opts.rb} +9 -12
  200. data/lib/lono/{s3.rb → cli/s3.rb} +9 -7
  201. data/lib/lono/cli/script/base.rb +5 -0
  202. data/lib/lono/cli/script/build.rb +72 -0
  203. data/lib/lono/cli/script/upload.rb +49 -0
  204. data/lib/lono/{script.rb → cli/script.rb} +2 -2
  205. data/lib/lono/cli/seed.rb +9 -0
  206. data/lib/lono/cli/test.rb +35 -0
  207. data/lib/lono/cli.rb +80 -106
  208. data/lib/lono/command.rb +27 -0
  209. data/lib/lono/configset/{generator.rb → builder.rb} +9 -7
  210. data/lib/lono/configset/combiner.rb +8 -6
  211. data/lib/lono/configset/evaluate_file.rb +1 -1
  212. data/lib/lono/configset/meta.rb +1 -1
  213. data/lib/lono/configset/s3_file/build.rb +5 -4
  214. data/lib/lono/configset/s3_file/item.rb +1 -1
  215. data/lib/lono/configset/s3_file/upload.rb +2 -2
  216. data/lib/lono/configset/strategy/base.rb +6 -6
  217. data/lib/lono/configset/strategy/helpers/dsl/core.rb +1 -1
  218. data/lib/lono/core.rb +25 -54
  219. data/lib/lono/extensions/dsl.rb +2 -5
  220. data/lib/lono/extensions/loader.rb +1 -12
  221. data/lib/lono/extensions.rb +2 -2
  222. data/lib/lono/importer/base.rb +5 -5
  223. data/lib/lono/importer/download.rb +7 -7
  224. data/lib/lono/importer/dsl.rb +3 -3
  225. data/lib/lono/importer/service/coder.rb +10 -10
  226. data/lib/lono/importer.rb +1 -10
  227. data/lib/lono/inspector/base.rb +7 -7
  228. data/lib/lono/inspector/summary.rb +19 -17
  229. data/lib/lono/layering/layer.rb +126 -0
  230. data/lib/lono/layering.rb +13 -55
  231. data/lib/lono/logger/formatter.rb +13 -0
  232. data/lib/lono/logger.rb +33 -0
  233. data/lib/lono/lookup.rb +12 -0
  234. data/lib/lono/names.rb +50 -0
  235. data/lib/lono/plugin/meta.rb +30 -0
  236. data/lib/lono/plugin/tester.rb +13 -0
  237. data/lib/lono/plugin.rb +10 -0
  238. data/lib/lono/s3/aws_setup.rb +4 -3
  239. data/lib/lono/s3/bucket.rb +19 -19
  240. data/lib/lono/s3/uploader.rb +10 -12
  241. data/lib/lono/script/base.rb +3 -3
  242. data/lib/lono/script/build.rb +11 -12
  243. data/lib/lono/script/upload.rb +7 -7
  244. data/lib/lono/{seed → seeder}/service_role.rb +1 -1
  245. data/lib/lono/{seed/base.rb → seeder.rb} +21 -36
  246. data/lib/lono/user_data.rb +8 -13
  247. data/lib/lono/utils/context.rb +15 -0
  248. data/lib/lono/utils/item/zip.rb +5 -5
  249. data/lib/lono/utils/logging.rb +7 -0
  250. data/lib/lono/utils/{pretty_time.rb → pretty.rb} +6 -2
  251. data/lib/lono/utils/quit.rb +7 -0
  252. data/lib/lono/utils/rsync.rb +4 -2
  253. data/lib/lono/utils/sure.rb +4 -4
  254. data/lib/lono/version.rb +1 -1
  255. data/lib/lono.rb +7 -11
  256. data/lib/templates/blueprint/template.rb +2 -0
  257. data/lib/templates/configset/{lib/configset.rb → configset.rb} +0 -0
  258. data/lib/templates/examples/blueprint/template.rb +9 -0
  259. data/lib/templates/helper/%underscore_name%_helper.rb.tt +6 -0
  260. data/lib/templates/{skeleton → project}/.gitignore +1 -2
  261. data/lib/templates/project/Gemfile.tt +11 -0
  262. data/lib/templates/project/README.md +9 -0
  263. data/lib/templates/project/config/app.rb +3 -0
  264. data/lib/templates/shim/lono +7 -0
  265. data/lono.gemspec +51 -43
  266. metadata +261 -264
  267. data/.circleci/README.md +0 -3
  268. data/.circleci/config.yml +0 -58
  269. data/.cody/acceptance.sh +0 -49
  270. data/.cody/buildspec.yml +0 -9
  271. data/.cody/demo.rb +0 -38
  272. data/.cody/project.rb +0 -6
  273. data/.gitmodules +0 -3
  274. data/lib/lono/abstract_base.rb +0 -25
  275. data/lib/lono/aws_services/stack.rb +0 -41
  276. data/lib/lono/aws_services/stack_set.rb +0 -41
  277. data/lib/lono/blueprint/configset/loader.rb +0 -7
  278. data/lib/lono/blueprint/helper.rb +0 -24
  279. data/lib/lono/blueprint/meta.rb +0 -30
  280. data/lib/lono/blueprint/new.rb +0 -127
  281. data/lib/lono/blueprint/root.rb +0 -25
  282. data/lib/lono/cfn/create.rb +0 -41
  283. data/lib/lono/cfn/opts.rb +0 -88
  284. data/lib/lono/cfn/preview/changeset.rb +0 -168
  285. data/lib/lono/cfn/preview/codediff.rb +0 -41
  286. data/lib/lono/cfn/preview/diff_viewer.rb +0 -23
  287. data/lib/lono/cfn/rollback.rb +0 -26
  288. data/lib/lono/cfn/update.rb +0 -71
  289. data/lib/lono/cfn.rb +0 -75
  290. data/lib/lono/clean.rb +0 -14
  291. data/lib/lono/configset/list.rb +0 -67
  292. data/lib/lono/configset/preparer.rb +0 -44
  293. data/lib/lono/configset/register/base.rb +0 -122
  294. data/lib/lono/configset/register/blueprint.rb +0 -16
  295. data/lib/lono/configset/register/dsl.rb +0 -14
  296. data/lib/lono/configset/register/project.rb +0 -13
  297. data/lib/lono/configset/resolver.rb +0 -47
  298. data/lib/lono/configset.rb +0 -16
  299. data/lib/lono/conventions.rb +0 -23
  300. data/lib/lono/core/config.rb +0 -22
  301. data/lib/lono/default/settings.yml +0 -21
  302. data/lib/lono/ext/bundler.rb +0 -7
  303. data/lib/lono/extension/helper.rb +0 -13
  304. data/lib/lono/extension/list.rb +0 -40
  305. data/lib/lono/extension.rb +0 -9
  306. data/lib/lono/extensions/preparer.rb +0 -26
  307. data/lib/lono/extensions/register.rb +0 -15
  308. data/lib/lono/file_uploader.rb +0 -21
  309. data/lib/lono/finder/base.rb +0 -152
  310. data/lib/lono/finder/blueprint/configset.rb +0 -17
  311. data/lib/lono/finder/blueprint.rb +0 -11
  312. data/lib/lono/finder/configset.rb +0 -11
  313. data/lib/lono/finder/extension.rb +0 -11
  314. data/lib/lono/generate.rb +0 -107
  315. data/lib/lono/help/cfn/create.md +0 -26
  316. data/lib/lono/help/cfn/delete.md +0 -13
  317. data/lib/lono/help/cfn/deploy.md +0 -21
  318. data/lib/lono/help/cfn/download.md +0 -3
  319. data/lib/lono/help/cfn/update.md +0 -49
  320. data/lib/lono/help/cfn.md +0 -7
  321. data/lib/lono/help/new.md +0 -57
  322. data/lib/lono/help/param.md +0 -6
  323. data/lib/lono/help/sets/delete.md +0 -8
  324. data/lib/lono/help/sets/deploy.md +0 -76
  325. data/lib/lono/help/sets/instances/delete.md +0 -21
  326. data/lib/lono/help/sets/instances/list.md +0 -14
  327. data/lib/lono/help/sets/instances/status.md +0 -15
  328. data/lib/lono/help/sets/instances/sync.md +0 -90
  329. data/lib/lono/help/sets/status.md +0 -23
  330. data/lib/lono/help/summary.md +0 -33
  331. data/lib/lono/help/template/generate.md +0 -7
  332. data/lib/lono/help/upgrade.md +0 -1
  333. data/lib/lono/help/xgraph.md +0 -16
  334. data/lib/lono/help.rb +0 -15
  335. data/lib/lono/importer/erb.rb +0 -31
  336. data/lib/lono/inspector/graph.rb +0 -125
  337. data/lib/lono/jade/circular.rb +0 -26
  338. data/lib/lono/jade/materializer/final.rb +0 -10
  339. data/lib/lono/jade/materializer/gems_builder.rb +0 -81
  340. data/lib/lono/jade/materializer/source.rb +0 -54
  341. data/lib/lono/jade/materializer.rb +0 -15
  342. data/lib/lono/jade/registry.rb +0 -64
  343. data/lib/lono/jade.rb +0 -110
  344. data/lib/lono/jadespec.rb +0 -68
  345. data/lib/lono/new/helper.rb +0 -15
  346. data/lib/lono/new.rb +0 -95
  347. data/lib/lono/param.rb +0 -14
  348. data/lib/lono/pro/base.rb +0 -16
  349. data/lib/lono/pro/repo.rb +0 -28
  350. data/lib/lono/pro.rb +0 -15
  351. data/lib/lono/project_checker.rb +0 -35
  352. data/lib/lono/registration/base.rb +0 -37
  353. data/lib/lono/registration/check.rb +0 -15
  354. data/lib/lono/registration/temp.rb +0 -53
  355. data/lib/lono/registration/user.rb +0 -60
  356. data/lib/lono/seed.rb +0 -39
  357. data/lib/lono/sequence.rb +0 -35
  358. data/lib/lono/sets/base.rb +0 -50
  359. data/lib/lono/sets/create.rb +0 -30
  360. data/lib/lono/sets/delete.rb +0 -52
  361. data/lib/lono/sets/deploy.rb +0 -11
  362. data/lib/lono/sets/instances/base.rb +0 -30
  363. data/lib/lono/sets/instances/delete.rb +0 -69
  364. data/lib/lono/sets/instances/list.rb +0 -13
  365. data/lib/lono/sets/instances/opts.rb +0 -29
  366. data/lib/lono/sets/instances/status.rb +0 -12
  367. data/lib/lono/sets/instances/sync.rb +0 -180
  368. data/lib/lono/sets/instances.rb +0 -33
  369. data/lib/lono/sets/list.rb +0 -35
  370. data/lib/lono/sets/opts.rb +0 -18
  371. data/lib/lono/sets/preview/codediff.rb +0 -35
  372. data/lib/lono/sets/preview/param.rb +0 -32
  373. data/lib/lono/sets/status/instance/base.rb +0 -120
  374. data/lib/lono/sets/status/instance/completed.rb +0 -35
  375. data/lib/lono/sets/status/instance/deleted.rb +0 -32
  376. data/lib/lono/sets/status/instance/show.rb +0 -7
  377. data/lib/lono/sets/status/instance.rb +0 -20
  378. data/lib/lono/sets/status/instances.rb +0 -133
  379. data/lib/lono/sets/status.rb +0 -116
  380. data/lib/lono/sets/summarize.rb +0 -20
  381. data/lib/lono/sets/time_spent.rb +0 -11
  382. data/lib/lono/sets/update.rb +0 -81
  383. data/lib/lono/sets.rb +0 -38
  384. data/lib/lono/setting.rb +0 -75
  385. data/lib/lono/template/aws_service.rb +0 -20
  386. data/lib/lono/template/bashify.rb +0 -39
  387. data/lib/lono/template/context/loader.rb +0 -52
  388. data/lib/lono/template/generator.rb +0 -23
  389. data/lib/lono/template/helper.rb +0 -152
  390. data/lib/lono/template/strategy/base.rb +0 -4
  391. data/lib/lono/template/strategy/common/helpers.rb +0 -44
  392. data/lib/lono/template/strategy/dsl/builder/section/base.rb +0 -30
  393. data/lib/lono/template/strategy/dsl/builder.rb +0 -59
  394. data/lib/lono/template/strategy/dsl.rb +0 -14
  395. data/lib/lono/template/strategy/erb.rb +0 -82
  396. data/lib/lono/template/strategy/source.rb +0 -8
  397. data/lib/lono/template/template.rb +0 -54
  398. data/lib/lono/template/util.rb +0 -8
  399. data/lib/lono/template.rb +0 -24
  400. data/lib/lono/upgrade.rb +0 -20
  401. data/lib/lono/utils/generators/tree.rb +0 -18
  402. data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +0 -45
  403. data/lib/templates/blueprint/.gitignore +0 -11
  404. data/lib/templates/blueprint/CHANGELOG.md +0 -7
  405. data/lib/templates/blueprint/Gemfile +0 -4
  406. data/lib/templates/blueprint/README.md.tt +0 -33
  407. data/lib/templates/blueprint/Rakefile.tt +0 -9
  408. data/lib/templates/blueprint/seed/configs.rb +0 -28
  409. data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +0 -36
  410. data/lib/templates/blueprint_types/dsl/app/user_data/bootstrap.sh +0 -2
  411. data/lib/templates/blueprint_types/erb/app/definitions/base.rb.tt +0 -1
  412. data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +0 -67
  413. data/lib/templates/configset/%configset_name%.gemspec.tt +0 -42
  414. data/lib/templates/configset/.gitignore +0 -10
  415. data/lib/templates/configset/CHANGELOG.md +0 -7
  416. data/lib/templates/configset/Gemfile +0 -4
  417. data/lib/templates/configset/README.md.tt +0 -3
  418. data/lib/templates/configset/Rakefile.tt +0 -9
  419. data/lib/templates/extension/%extension_name%.gemspec.tt +0 -46
  420. data/lib/templates/extension/.gitignore +0 -11
  421. data/lib/templates/extension/.rspec +0 -3
  422. data/lib/templates/extension/CHANGELOG.md +0 -7
  423. data/lib/templates/extension/Gemfile.tt +0 -4
  424. data/lib/templates/extension/Rakefile.tt +0 -9
  425. data/lib/templates/extension/spec/spec_helper.rb.tt +0 -29
  426. data/lib/templates/skeleton/Gemfile +0 -3
  427. data/lib/templates/skeleton/README.md +0 -58
  428. data/lib/templates/skeleton/configs/settings.yml +0 -13
  429. data/vendor/cfn-status/CHANGELOG.md +0 -14
  430. data/vendor/cfn-status/Gemfile +0 -4
  431. data/vendor/cfn-status/Gemfile.lock +0 -49
  432. data/vendor/cfn-status/LICENSE.txt +0 -21
  433. data/vendor/cfn-status/README.md +0 -58
  434. data/vendor/cfn-status/Rakefile +0 -6
  435. data/vendor/cfn-status/bin/console +0 -14
  436. data/vendor/cfn-status/bin/setup +0 -8
  437. data/vendor/cfn-status/cfn-status.gemspec +0 -30
  438. data/vendor/cfn-status/lib/cfn-status.rb +0 -1
  439. data/vendor/cfn-status/lib/cfn_status/aws_service.rb +0 -51
  440. data/vendor/cfn-status/lib/cfn_status/version.rb +0 -3
  441. data/vendor/cfn-status/lib/cfn_status.rb +0 -245
  442. data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-1.json +0 -1103
  443. data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-2.json +0 -1104
  444. data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-3.json +0 -1103
  445. data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-1.json +0 -1103
  446. data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-2.json +0 -1104
  447. data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-3.json +0 -1103
  448. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +0 -1080
  449. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +0 -1080
  450. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +0 -1086
  451. data/vendor/cfn-status/spec/lib/cfn_status_spec.rb +0 -153
  452. data/vendor/cfn-status/spec/spec_helper.rb +0 -14
data/lib/lono/cfn/base.rb CHANGED
@@ -1,202 +1,15 @@
1
- require "lono"
2
-
3
- class Lono::Cfn
4
- class Base < Lono::AbstractBase
1
+ module Lono::Cfn
2
+ class Base < Lono::CLI::Base
5
3
  extend Memoist
4
+
6
5
  include Lono::AwsServices
7
6
  include Lono::Utils::Sure
7
+ include Lono::Utils::Logging
8
+ include Lono::Utils::Pretty
9
+ include Lono::Utils::Quit
8
10
 
9
- def starting_message
10
- action = self.class.to_s.split('::').last
11
- puts "#{action} #{@stack.color(:green)} stack..."
12
- end
13
-
14
- def run
15
- starting_message
16
- parameters = generate_all
17
- begin
18
- save(parameters) # defined in the sub class
19
- rescue Aws::CloudFormation::Errors::InsufficientCapabilitiesException => e
20
- yes = rerun_with_iam?(e)
21
- retry if yes
22
- rescue Aws::CloudFormation::Errors::ValidationError => e
23
- if e.message.include?("No updates") # No updates are to be performed.
24
- puts "WARN: #{e.message}".color(:yellow)
25
- elsif e.message.include?("UPDATE_ROLLBACK_FAILED") # https://amzn.to/2IiEjc5
26
- continue_update_rollback
27
- else
28
- puts "ERROR: #{e.message}".color(:red)
29
- exit 1
30
- end
31
- end
32
-
33
- return unless @options[:wait]
34
-
35
- success = false
36
- if !@options[:noop]
37
- success = status.wait
38
- end
39
-
40
- # exit code for cfn.rb cli, so there's less duplication
41
- exit 1 unless success
42
- Lono::Registration.check
43
- success
44
- end
45
-
46
- def continue_update_rollback_sure?
47
- puts <<~EOL
48
- The stack is in the UPDATE_ROLLBACK_FAILED state. More info here: https://amzn.to/2IiEjc5
49
- Would you like to try to continue the update rollback? (y/N)
50
- EOL
51
-
52
- sure = @options[:sure] ? "y" : $stdin.gets
53
- unless sure =~ /^y/
54
- puts "Exiting without continuing the update rollback."
55
- exit 0
56
- end
57
- end
58
-
59
- def continue_update_rollback
60
- continue_update_rollback_sure?
61
- options = {stack_name: @stack}
62
- show_options(options, "cfn.continue_update_rollback")
63
- begin
64
- cfn.continue_update_rollback(options)
65
- rescue Aws::CloudFormation::Errors::ValidationError => e
66
- puts "ERROR5: #{e.message}".color(:red)
67
- exit 1
68
- end
69
- end
70
-
71
- def delete_rollback_stack
72
- rollback = Rollback.new(@stack)
73
- rollback.delete_stack
74
- end
75
-
76
- def status
77
- Status.new(@stack)
78
- end
79
- memoize :status
80
-
81
- def rerun_with_iam?(e)
82
- # e.message is "Requires capabilities : [CAPABILITY_IAM]"
83
- # grab CAPABILITY_IAM with regexp
84
- capabilities = e.message.match(/\[(.*)\]/)[1]
85
- confirm = prompt_for_iam(capabilities)
86
- if confirm =~ /^y/
87
- @options.merge!(capabilities: [capabilities])
88
- puts "Re-running: #{command_with_iam(capabilities).color(:green)}"
89
- true
90
- else
91
- puts "Exited"
92
- exit 1
93
- end
94
- end
95
-
96
- def prompt_for_iam(capabilities)
97
- puts "This stack will create IAM resources. Please approve to run the command again with #{capabilities} capabilities."
98
- puts " #{command_with_iam(capabilities)}"
99
-
100
- puts "Please confirm (y/N)"
101
- $stdin.gets
102
- end
103
-
104
- def command_with_iam(capabilities)
105
- "#{File.basename($0)} #{ARGV.join(' ')} --capabilities #{capabilities}"
106
- end
107
-
108
- def generate_all
109
- Lono::Generate.new(@options).all
110
- end
111
-
112
- # Maps to CloudFormation format. Example:
113
- #
114
- # {"a"=>"1", "b"=>"2"}
115
- # To
116
- # [{key: "a", value: "1"}, {key: "b", value: "2"}]
117
- #
118
- def tags
119
- tags = @options[:tags] || []
120
- tags = tags.map do |k,v|
121
- { key: k, value: v }
122
- end
123
-
124
- update_operation = %w[Preview Update].include?(self.class.to_s)
125
- if tags.empty? && update_operation
126
- resp = cfn.describe_stacks(stack_name: @stack)
127
- tags = resp.stacks.first.tags
128
- tags = tags.map(&:to_h)
129
- end
130
-
131
- tags
132
- end
133
-
134
- def exit_unless_updatable!
135
- return true if testing_update?
136
- return false if @options[:noop]
137
-
138
- status = stack_status
139
- unless status =~ /_COMPLETE$/ || status == "UPDATE_ROLLBACK_FAILED"
140
- puts "Cannot create a change set for the stack because the #{@stack} is not in an updatable state. Stack status: #{status}".color(:red)
141
- quit(1)
142
- end
143
- end
144
-
145
- # All CloudFormation states listed here:
146
- # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html
147
- def stack_status
148
- return true if testing_update?
149
- return false if @options[:noop]
150
- resp = cfn.describe_stacks(stack_name: @stack)
151
- resp.stacks[0].stack_status
152
- end
153
-
154
- # To allow mocking in specs
155
- def quit(signal)
156
- exit signal
157
- end
158
-
159
- def capabilities
160
- return @options[:capabilities] if @options[:capabilities]
161
- if @options[:sure] || @options[:iam]
162
- ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM", "CAPABILITY_AUTO_EXPAND"]
163
- end
164
- end
165
-
166
- def notification_arns
167
- @setting ||= Lono::Setting.new
168
- settings = @setting.data
169
- arns = @options["notification_arns"] || settings["notification_arns"]
170
- arns == [''] ? [] : arns # allow removing the notification_arns setting
171
- end
172
-
173
- def show_options(options, meth=nil)
174
- options = options.clone.compact
175
- if options[:template_body] # continue_update_rollback
176
- options[:template_body] = "Hidden due to size... View at: #{pretty_path(template_path)}"
177
- options[:template_url] = options[:template_url].sub(/\?.*/,'')
178
- end
179
- to = meth || "AWS API"
180
- puts "Parameters passed to #{to}:"
181
- puts YAML.dump(options.deep_stringify_keys)
182
- end
183
-
184
- # Lono always uploads the template to s3 so we can use much larger templates.
185
- #
186
- # template_body: 51,200 bytes - filesystem limit
187
- # template_url: 460,800 bytes - s3 limit
188
- #
189
- # Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html
190
- def set_template_url!(options)
191
- url_path = template_path.sub("#{Lono.root}/",'')
192
- url = Lono::S3::Uploader.new(url_path).presigned_url
193
- url.gsub!(/\.yml.*/, ".yml") # Interesting dont need presign query string. For stack sets it actually breaks it. So removing.
194
- options[:template_url] = url
195
- options
196
- end
11
+ include Concerns
197
12
 
198
- def pretty_path(path)
199
- path.sub("#{Lono.root}/",'')
200
- end
13
+ delegate :template_path, to: :build
201
14
  end
202
- end
15
+ end
@@ -1,41 +1,24 @@
1
- class Lono::Cfn
2
- class Cancel
3
- include Lono::AwsServices
4
- include Lono::Utils::Sure
5
-
6
- def initialize(options={})
7
- @options = options
8
- @stack = options[:stack]
9
- end
10
-
1
+ module Lono::Cfn
2
+ class Cancel < Base
11
3
  def run
12
- if @options[:noop]
13
- puts "NOOP Canceling #{@stack} stack"
14
- return
15
- end
16
-
17
4
  stack = find_stack(@stack)
18
5
  unless stack
19
- puts "The '#{@stack}' stack does not exist. Unable to cancel"
20
- exit 1
6
+ logger.info "The '#{@stack}' stack does not exist. Unable to cancel"
7
+ quit 1
21
8
  end
22
9
 
23
- puts "Canceling updates to #{@stack}."
24
- puts "Current stack status: #{stack.stack_status}"
10
+ logger.info "Canceling updates to #{@stack}."
11
+ logger.info "Current stack status: #{stack.stack_status}"
25
12
  if stack.stack_status == "CREATE_IN_PROGRESS"
26
13
  cfn.delete_stack(stack_name: @stack)
27
- puts "Canceling stack creation."
14
+ logger.info "Canceling stack creation."
28
15
  elsif stack.stack_status == "UPDATE_IN_PROGRESS"
29
16
  cfn.cancel_update_stack(stack_name: @stack)
30
- puts "Canceling stack update."
17
+ logger.info "Canceling stack update."
31
18
  status.wait if @options[:wait]
32
19
  else
33
- puts "The stack is not in a state to that is cancelable: #{stack.stack_status}"
20
+ logger.info "The stack is not in a state to that is cancelable: #{stack.stack_status}"
34
21
  end
35
22
  end
36
-
37
- def status
38
- @status ||= Status.new(@stack)
39
- end
40
23
  end
41
24
  end
@@ -0,0 +1,10 @@
1
+ module Lono::Cfn::Concerns
2
+ module Build
3
+ extend Memoist
4
+
5
+ def build
6
+ Lono::CLI::Build.new(@options)
7
+ end
8
+ memoize :build
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Lono::Cfn::Concerns
2
+ module TemplateOutput
3
+ extend Memoist
4
+
5
+ def template_output
6
+ Lono::Builder::Template::Output.new(@blueprint)
7
+ end
8
+ memoize :template_output
9
+ end
10
+ end
@@ -0,0 +1,43 @@
1
+ module Lono::Cfn
2
+ module Concerns
3
+ extend Memoist
4
+
5
+ include Concerns::Build
6
+ include Concerns::TemplateOutput
7
+
8
+ def iam
9
+ Deploy::Iam.new(@options)
10
+ end
11
+ memoize :iam
12
+
13
+ def notification
14
+ Deploy::Notification.new(@options)
15
+ end
16
+ memoize :notification
17
+
18
+ def rollback
19
+ Deploy::Rollback.new(@options)
20
+ end
21
+ memoize :rollback
22
+
23
+ def operable
24
+ Deploy::Operable.new(@options)
25
+ end
26
+ memoize :operable
27
+
28
+ def plan
29
+ Plan.new(@options.merge(build: build, iam: iam))
30
+ end
31
+ memoize :plan
32
+
33
+ def status
34
+ Status.new(@stack)
35
+ end
36
+ memoize :status
37
+
38
+ def tags
39
+ Deploy::Tags.new(@options)
40
+ end
41
+ memoize :tags
42
+ end
43
+ end
@@ -1,38 +1,14 @@
1
- class Lono::Cfn
2
- class Delete
3
- include Lono::AwsServices
4
- include Lono::Utils::Sure
5
-
6
- def initialize(options={})
7
- @options = options
8
- @stack = options.delete(:stack)
9
- end
10
-
1
+ module Lono::Cfn
2
+ class Delete < Base
11
3
  def run
12
- message = "Deleting #{@stack} stack."
13
- if @options[:noop]
14
- puts "NOOP #{message}"
4
+ plan.for_delete
5
+ sure?("Are you sure you want to delete the #{@stack} stack?")
6
+ cfn.delete_stack(stack_name: @stack)
7
+ if @options[:wait]
8
+ status.wait
15
9
  else
16
- sure?("Are you sure you want to delete the #{@stack} stack?")
17
-
18
- if stack_exists?(@stack)
19
- cfn.delete_stack(stack_name: @stack)
20
- puts message
21
- else
22
- puts "#{@stack.inspect} stack does not exist".color(:red)
23
- return
24
- end
10
+ logger.info "Deleting stack #{@stack}"
25
11
  end
26
-
27
- return unless @options[:wait]
28
- start_time = Time.now
29
- status.wait unless @options[:noop]
30
- took = Time.now - start_time
31
- puts "Time took for stack deletion: #{status.pretty_time(took).color(:green)}."
32
- end
33
-
34
- def status
35
- @status ||= Status.new(@stack)
36
12
  end
37
13
  end
38
14
  end
@@ -0,0 +1,4 @@
1
+ class Lono::Cfn::Deploy
2
+ class Base < Lono::Cfn::Base
3
+ end
4
+ end
@@ -0,0 +1,49 @@
1
+ class Lono::Cfn::Deploy
2
+ class Iam < Base
3
+ attr_reader :options
4
+
5
+ def rerun?(e)
6
+ # e.message is "Requires capabilities : [CAPABILITY_IAM]"
7
+ # grab CAPABILITY_IAM with regexp
8
+ capabilities = e.message.match(/\[(.*)\]/)[1]
9
+ confirm = prompt(capabilities)
10
+ if confirm =~ /^y/
11
+ logger.info "Re-running: #{command_with_iam(capabilities).color(:green)}"
12
+ @retry_capabilities = [capabilities]
13
+ true
14
+ else
15
+ logger.info "Exited"
16
+ quit 1
17
+ end
18
+ end
19
+
20
+ def prompt(capabilities)
21
+ logger.info <<~EOL
22
+ This stack will create IAM resources. Please approve to run the command again with #{capabilities} capabilities.
23
+
24
+ #{command_with_iam(capabilities)}
25
+
26
+ You can also avoid this prompt with config.up.capabilities in config/app.rb.
27
+ See: https://lono.cloud/docs/config/reference/
28
+
29
+ EOL
30
+ logger.print "Please confirm (y/N) "
31
+ $stdin.gets
32
+ end
33
+
34
+ def command_with_iam(capabilities)
35
+ "lono #{Lono.argv.join(' ')} --capabilities #{capabilities}"
36
+ end
37
+
38
+ def capabilities
39
+ return @retry_capabilities if @retry_capabilities
40
+ return @options[:capabilities] if @options[:capabilities]
41
+ if @options[:iam]
42
+ ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM", "CAPABILITY_AUTO_EXPAND"]
43
+ else
44
+ Lono.config.up.capabilities
45
+ end
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,8 @@
1
+ class Lono::Cfn::Deploy
2
+ class Notification < Base
3
+ def arns
4
+ arns = @options["notification_arns"] || Lono.config.up.notification_arns
5
+ arns == [''] ? [] : arns # allow removing the notification_arns setting
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ class Lono::Cfn::Deploy
2
+ class Operable < Base
3
+ def check!
4
+ status = stack_status
5
+ unless status =~ /_COMPLETE$/ || status == "UPDATE_ROLLBACK_FAILED"
6
+ logger.info "Cannot create run operation on stack #{@stack} is not in an updatable state. Stack status: #{status}".color(:red)
7
+ quit 1
8
+ end
9
+ end
10
+
11
+ # All CloudFormation states listed here:
12
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html
13
+ def stack_status
14
+ resp = cfn.describe_stacks(stack_name: @stack)
15
+ resp.stacks[0].stack_status
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,49 @@
1
+ class Lono::Cfn::Deploy
2
+ class Opts < Base
3
+ def initialize(blueprint, meth, iam, options={})
4
+ @blueprint, @meth, @iam, @options = blueprint, meth, iam, options
5
+ end
6
+
7
+ def values
8
+ # important to use local options variable to not stomp on @options
9
+ options = @options.clone.compact
10
+ options[:capabilities] = @iam.capabilities if @iam.capabilities
11
+ options[:disable_rollback] = disable_rollback if !disable_rollback.nil? && @meth != "create_change_set"
12
+ options[:notification_arns] = notification.arns if notification.arns
13
+ options[:tags] = tags.values unless tags.values.nil?
14
+ options[:template_url] = template_url
15
+ options.reject { |k,v| v.nil? }
16
+ end
17
+
18
+ def show
19
+ logger.debug "Options passed to #{@meth}"
20
+ vals = values
21
+ vals[:template_body] = "Hidden due to size... View at: #{pretty_path(@blueprint.output_path)}" if vals[:template_body]
22
+ logger.debug YAML.dump(vals.deep_stringify_keys)
23
+ end
24
+
25
+ # Uploads the template to s3 to allow larger templates.
26
+ #
27
+ # template_body: 51,200 bytes - filesystem limit
28
+ # template_url: 1MB - s3 limit
29
+ #
30
+ # Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html
31
+ def template_url
32
+ url_path = @blueprint.output_path.sub("#{Lono.root}/",'')
33
+ url = Lono::S3::Uploader.new(url_path).presigned_url
34
+ # Interesting dont need presign query string. For stack sets it actually breaks it. So removing.
35
+ url.gsub!(/\.yml.*/, ".yml")
36
+ url.sub!(/\?.*/,'')
37
+ url
38
+ end
39
+ memoize :template_url
40
+
41
+ def disable_rollback
42
+ if !@options[:rollback].nil?
43
+ !@options[:rollback]
44
+ elsif !Lono.config.up.rollback.nil?
45
+ !Lono.config.up.rollback
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,46 @@
1
+ class Lono::Cfn::Deploy
2
+ class Rollback < Base
3
+ def delete_stack
4
+ return unless complete?
5
+ logger.info "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
6
+ cfn.delete_stack(stack_name: @stack)
7
+ status.wait
8
+ status.reset
9
+ true
10
+ end
11
+
12
+ def continue_update
13
+ continue_update?
14
+ options = {stack_name: @stack}
15
+ show_options(options, "continue_update_rollback")
16
+ begin
17
+ cfn.continue_update_rollback(options)
18
+ rescue Aws::CloudFormation::Errors::ValidationError => e
19
+ logger.info "ERROR: Continue update: #{e.message}".color(:red)
20
+ quit 1
21
+ end
22
+ end
23
+
24
+ def continue_update?
25
+ logger.info <<~EOL
26
+ The stack is in the UPDATE_ROLLBACK_FAILED state. More info here: https://amzn.to/2IiEjc5
27
+ Would you like to try to continue the update rollback? (y/N)
28
+ EOL
29
+
30
+ yes = @options[:yes] ? "y" : $stdin.gets
31
+ unless yes =~ /^y/
32
+ logger.info "Exiting without continuing the update rollback."
33
+ quit 0
34
+ end
35
+ end
36
+
37
+ def complete?
38
+ stack&.stack_status == 'ROLLBACK_COMPLETE'
39
+ end
40
+
41
+ def stack
42
+ find_stack(@stack)
43
+ end
44
+ memoize :stack
45
+ end
46
+ end
@@ -0,0 +1,18 @@
1
+ class Lono::Cfn::Deploy
2
+ class Tags < Base
3
+ # Maps to CloudFormation format. Example:
4
+ #
5
+ # {"a"=>"1", "b"=>"2"}
6
+ # To
7
+ # [{key: "a", value: "1"}, {key: "b", value: "2"}]
8
+ #
9
+ def values
10
+ tags = Lono.config.up.tags
11
+ return if tags.nil? # nil = keep current tags. [] = remove all tags
12
+
13
+ tags.map do |k,v|
14
+ { key: k.to_s, value: v }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,11 +1,77 @@
1
- class Lono::Cfn
1
+ module Lono::Cfn
2
2
  class Deploy < Base
3
- def save(parameters)
4
- if stack_exists?(@stack)
5
- Update.new(@options).save(parameters)
3
+ def run
4
+ start_message
5
+ perform # create or update
6
+ success = status.wait
7
+ if success
8
+ finish_message
9
+ logger.info "" # newline
10
+ end
11
+ outputs
12
+ end
13
+
14
+ def perform
15
+ build.all
16
+ @action = create? ? "create" : "update"
17
+ send(@action)
18
+ rescue Aws::CloudFormation::Errors::InsufficientCapabilitiesException => e
19
+ @sure = true
20
+ yes = iam.rerun?(e)
21
+ retry if yes
22
+ rescue Aws::CloudFormation::Errors::ValidationError => e
23
+ if e.message.include?("No updates") # No updates are to be performed.
24
+ logger.info "WARN: #{e.message}".color(:yellow)
25
+ elsif e.message.include?("UPDATE_ROLLBACK_FAILED") # https://amzn.to/2IiEjc5
26
+ rollback.continue_update
6
27
  else
7
- Create.new(@options).save(parameters)
28
+ logger.info "ERROR: #{e.message}".color(:red)
29
+ quit 1
30
+ end
31
+ end
32
+
33
+ def create
34
+ plan.for_create
35
+ @sure || sure?("Going to create stack #{@stack} with blueprint #{@blueprint.name}.")
36
+
37
+ options = {
38
+ stack_name: @stack,
39
+ parameters: build.parameters,
40
+ }
41
+ opts = Opts.new(@blueprint, "create_stack", iam, options)
42
+ opts.show
43
+ options = opts.values
44
+ cfn.create_stack(options)
45
+ end
46
+
47
+ def update
48
+ if rollback.delete_stack
49
+ create
50
+ return
8
51
  end
52
+
53
+ operable.check!
54
+ changeset = plan.for_update
55
+ !changeset.changed? || @sure || sure?("Are you sure you want to update the #{@stack} stack?")
56
+ changeset.execute_change_set
57
+ end
58
+
59
+ def create?
60
+ !stack_exists?(@stack)
61
+ end
62
+
63
+ def start_message
64
+ action = self.class.to_s.split('::').last
65
+ logger.info "#{action}ing #{@stack.color(:green)} stack"
66
+ end
67
+
68
+ def finish_message
69
+ message = "#{@action.capitalize}d #{@stack.color(:green)} stack."
70
+ logger.info message unless @options[:mute]
71
+ end
72
+
73
+ def outputs
74
+ Output.new(@options).run
9
75
  end
10
76
  end
11
77
  end
@@ -1,14 +1,12 @@
1
1
  require 'json'
2
2
  require 'open-uri'
3
3
 
4
- class Lono::Cfn
5
- class Download < Lono::AbstractBase
6
- include Lono::AwsServices
7
-
4
+ module Lono::Cfn
5
+ class Download < Base
8
6
  def run
9
7
  pretty_path = download_path.sub("#{Lono.root}/", '')
10
- puts "Downloading template to: #{pretty_path}"
11
- return if @options[:noop]
8
+ logger.info "Downloading template to: #{pretty_path}"
9
+ return if ENV['LONO_NOOP']
12
10
  download_template
13
11
  end
14
12
 
@@ -41,7 +39,7 @@ class Lono::Cfn
41
39
  end
42
40
 
43
41
  def download_path
44
- "#{Lono.config.output_path}/#{@blueprint}/templates/#{@blueprint}.yml"
42
+ "#{Lono.root}/output/#{@blueprint.name}/templates/#{@blueprint.name}.yml"
45
43
  end
46
44
 
47
45
  def name