lono 3.5.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -4
- data/.rspec +1 -0
- data/CHANGELOG.md +15 -1
- data/Gemfile +3 -3
- data/Guardfile +17 -8
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.md +20 -12
- data/Rakefile +1 -2
- data/{bin → exe}/lono +1 -0
- data/lib/lono.rb +12 -9
- data/lib/lono/cfn.rb +7 -9
- data/lib/lono/cfn/{aws_services.rb → aws_service.rb} +1 -1
- data/lib/lono/cfn/base.rb +41 -38
- data/lib/lono/cfn/create.rb +6 -2
- data/lib/lono/cfn/delete.rb +2 -2
- data/lib/lono/cfn/diff.rb +1 -1
- data/lib/lono/cfn/preview.rb +26 -15
- data/lib/lono/cfn/update.rb +11 -9
- data/lib/lono/cfn/util.rb +3 -3
- data/lib/lono/clean.rb +1 -1
- data/lib/lono/cli.rb +71 -39
- data/lib/lono/command.rb +42 -18
- data/lib/lono/completer.rb +162 -0
- data/lib/lono/completer/script.rb +6 -0
- data/lib/lono/completer/script.sh +10 -0
- data/lib/lono/completion.rb +15 -0
- data/lib/lono/core.rb +23 -9
- data/lib/lono/core/config.rb +20 -0
- data/lib/lono/default/settings.yml +33 -13
- data/lib/lono/help.rb +6 -79
- data/lib/lono/help/cfn.md +6 -0
- data/lib/lono/help/cfn/create.md +22 -0
- data/lib/lono/help/cfn/delete.md +5 -0
- data/lib/lono/help/cfn/diff.md +5 -0
- data/lib/lono/help/cfn/download.md +5 -0
- data/lib/lono/help/cfn/preview.md +11 -0
- data/lib/lono/help/cfn/update.md +21 -0
- data/lib/lono/help/completion.md +22 -0
- data/lib/lono/help/completion_script.md +3 -0
- data/lib/lono/help/generate.md +7 -0
- data/lib/lono/help/hello.md +5 -0
- data/lib/lono/help/import.md +7 -0
- data/lib/lono/help/inspect.md +4 -0
- data/lib/lono/help/inspect/depends.md +3 -0
- data/lib/lono/help/inspect/summary.md +3 -0
- data/lib/lono/help/new.md +8 -0
- data/lib/lono/help/param.md +3 -0
- data/lib/lono/{param/help.rb → help/param/generate.md} +1 -9
- data/lib/lono/help/script/build.md +5 -0
- data/lib/lono/help/script/upload.md +8 -0
- data/lib/lono/help/template.md +4 -0
- data/lib/lono/help/template/bashify.md +4 -0
- data/lib/lono/help/template/generate.md +7 -0
- data/lib/lono/help/user_data.md +3 -0
- data/lib/lono/importer.rb +43 -20
- data/lib/lono/inspector.rb +2 -19
- data/lib/lono/inspector/base.rb +2 -2
- data/lib/lono/inspector/{depends.rb → graph.rb} +3 -3
- data/lib/lono/inspector/summary.rb +1 -1
- data/lib/lono/new.rb +79 -26
- data/lib/lono/new/helper.rb +16 -0
- data/lib/lono/new/message.rb +35 -0
- data/lib/lono/param.rb +1 -2
- data/lib/lono/param/generator.rb +34 -86
- data/lib/lono/project_checker.rb +35 -40
- data/lib/lono/script.rb +19 -0
- data/lib/lono/script/base.rb +9 -0
- data/lib/lono/script/build.rb +73 -0
- data/lib/lono/script/upload.rb +81 -0
- data/lib/lono/sequence.rb +33 -0
- data/lib/lono/setting.rb +83 -0
- data/lib/lono/template.rb +8 -9
- data/lib/lono/template/{aws_services.rb → aws_service.rb} +1 -1
- data/lib/lono/template/context.rb +73 -0
- data/lib/lono/template/dsl.rb +63 -64
- data/lib/lono/template/helper.rb +201 -0
- data/lib/lono/template/template.rb +29 -221
- data/lib/lono/template/upload.rb +41 -33
- data/lib/lono/upgrade4.rb +175 -0
- data/lib/lono/user_data.rb +31 -0
- data/lib/lono/version.rb +1 -1
- data/lib/starter_projects/autoscaling/.gitignore +1 -0
- data/lib/starter_projects/{json_project → autoscaling}/Gemfile +0 -0
- data/lib/starter_projects/{yaml_project → autoscaling}/Guardfile +0 -0
- data/lib/starter_projects/autoscaling/README.md +118 -0
- data/lib/starter_projects/autoscaling/app/definitions/base.rb +2 -0
- data/lib/starter_projects/autoscaling/app/templates/autoscaling.yml +682 -0
- data/lib/starter_projects/autoscaling/config/params/base/autoscaling.txt +6 -0
- data/lib/starter_projects/autoscaling/config/settings.yml +33 -0
- data/lib/starter_projects/ec2/.gitignore +1 -0
- data/lib/starter_projects/{yaml_project → ec2}/Gemfile +0 -0
- data/lib/starter_projects/{json_project → ec2}/Guardfile +1 -1
- data/lib/starter_projects/ec2/README.md +86 -0
- data/lib/starter_projects/ec2/app/definitions/base.rb +2 -0
- data/lib/starter_projects/ec2/app/definitions/development.rb +1 -0
- data/lib/starter_projects/ec2/app/definitions/production.rb +1 -0
- data/lib/starter_projects/{yaml_project → ec2/app}/helpers/my_custom_helper.rb +0 -0
- data/lib/starter_projects/{json_project/templates/user_data/app.sh → ec2/app/partials/user_data/bootstrap.sh} +1 -2
- data/lib/starter_projects/{yaml_project → ec2/app}/templates/example.yml +0 -0
- data/lib/starter_projects/{json_project/params/base/api-web.txt → ec2/config/params/base/example.txt} +0 -0
- data/lib/starter_projects/ec2/config/params/development/example.txt +3 -0
- data/lib/starter_projects/ec2/config/params/production/example.txt +2 -0
- data/lib/starter_projects/ec2/config/settings.yml +33 -0
- data/lib/starter_projects/ec2/config/variables/base.rb +3 -0
- data/lib/starter_projects/ec2/config/variables/development.rb +2 -0
- data/lib/starter_projects/ec2/config/variables/production.rb +2 -0
- data/lib/starter_projects/ec2/welcome.txt +8 -0
- data/lib/starter_projects/skeleton/.gitignore +1 -0
- data/lib/starter_projects/skeleton/Gemfile +3 -0
- data/lib/starter_projects/skeleton/Guardfile +12 -0
- data/lib/starter_projects/skeleton/README.md +53 -0
- data/{spec/fixtures/my_project/templates/.gitkeep → lib/starter_projects/skeleton/app/definitions/base.rb} +0 -0
- data/lib/starter_projects/skeleton/config/settings.yml +33 -0
- data/lib/starter_projects/skeleton/welcome.txt +7 -0
- data/lono.gemspec +12 -10
- data/spec/fixtures/lono_project/.gitignore +1 -0
- data/spec/fixtures/lono_project/Gemfile +3 -0
- data/spec/fixtures/lono_project/Guardfile +12 -0
- data/spec/fixtures/lono_project/app/definitions/base.rb +10 -0
- data/spec/fixtures/lono_project/app/definitions/base/more.rb +7 -0
- data/spec/fixtures/lono_project/app/definitions/development.rb +1 -0
- data/spec/fixtures/lono_project/app/definitions/production.rb +1 -0
- data/spec/fixtures/lono_project/app/helpers/custom_helper.rb +5 -0
- data/spec/fixtures/lono_project/app/partials/security_group.yml +10 -0
- data/{lib/starter_projects/yaml_project/templates/partial → spec/fixtures/lono_project/app/partials}/user_data/bootstrap.sh +8 -2
- data/spec/fixtures/lono_project/app/templates/example.yml +50 -0
- data/{lib/starter_projects/yaml_project/params/base/api-web-prod.txt → spec/fixtures/lono_project/config/params/base/example.txt} +1 -0
- data/spec/fixtures/lono_project/config/params/development/example.txt +1 -0
- data/spec/fixtures/lono_project/config/params/production/example.txt +1 -0
- data/spec/fixtures/lono_project/config/settings.yml +31 -0
- data/spec/fixtures/lono_project/config/variables/base.rb +3 -0
- data/spec/fixtures/lono_project/config/variables/development.rb +1 -0
- data/spec/fixtures/lono_project/config/variables/production.rb +1 -0
- data/spec/fixtures/params/envonly/params/{prod → development}/network.txt +0 -0
- data/spec/fixtures/params/overlay/params/{prod → development}/network.txt +0 -0
- data/spec/fixtures/raw_templates/aws-waf-security-automations.template +2 -2
- data/spec/lib/lono/cfn_spec.rb +6 -9
- data/spec/lib/lono/cli_spec.rb +44 -0
- data/spec/lib/lono/completion_spec.rb +17 -0
- data/spec/lib/lono/inspect_spec.rb +6 -15
- data/spec/lib/lono/param/generator_spec.rb +45 -26
- data/spec/lib/lono/param_spec.rb +1 -3
- data/spec/lib/lono/setting_spec.rb +47 -0
- data/spec/lib/lono/template/dsl_spec.rb +33 -157
- data/spec/lib/lono/template_spec.rb +4 -16
- data/spec/spec_helper.rb +45 -14
- metadata +168 -82
- data/.coveralls.yml +0 -1
- data/lib/lono/cfn/help.rb +0 -103
- data/lib/lono/current_region.rb +0 -42
- data/lib/lono/inspector/help.rb +0 -21
- data/lib/lono/settings.rb +0 -45
- data/lib/lono/template/help.rb +0 -25
- data/lib/lono/template/helpers.rb +0 -136
- data/lib/starter_projects/json_project/.gitignore +0 -1
- data/lib/starter_projects/json_project/config/templates/base/blog.rb +0 -20
- data/lib/starter_projects/json_project/config/templates/base/stacks.rb +0 -58
- data/lib/starter_projects/json_project/templates/db.json +0 -212
- data/lib/starter_projects/json_project/templates/partial/host_record.json +0 -28
- data/lib/starter_projects/json_project/templates/partial/server.json +0 -45
- data/lib/starter_projects/json_project/templates/user_data/db.sh +0 -39
- data/lib/starter_projects/json_project/templates/user_data/db2.sh +0 -2
- data/lib/starter_projects/json_project/templates/user_data/ruby_script.rb +0 -5
- data/lib/starter_projects/json_project/templates/web.json +0 -386
- data/lib/starter_projects/yaml_project/.gitignore +0 -1
- data/lib/starter_projects/yaml_project/config/templates/base/blog.rb +0 -20
- data/lib/starter_projects/yaml_project/config/templates/base/stacks.rb +0 -56
- data/lib/starter_projects/yaml_project/config/templates/prod/stacks.rb +0 -1
- data/lib/starter_projects/yaml_project/config/templates/stag/stacks.rb +0 -1
- data/lib/starter_projects/yaml_project/config/variables/base/variables.rb +0 -4
- data/lib/starter_projects/yaml_project/config/variables/prod/variables.rb +0 -1
- data/lib/starter_projects/yaml_project/config/variables/stag/variables.rb +0 -1
- data/lib/starter_projects/yaml_project/params/base/example.txt +0 -2
- data/lib/starter_projects/yaml_project/params/prod/example.txt +0 -1
- data/lib/starter_projects/yaml_project/params/stag/example.txt +0 -1
- data/lib/starter_projects/yaml_project/templates/db.yml +0 -148
- data/lib/starter_projects/yaml_project/templates/partial/host_record.yml +0 -14
- data/lib/starter_projects/yaml_project/templates/partial/server.yml +0 -59
- data/lib/starter_projects/yaml_project/templates/web.yml +0 -206
- data/spec/fixtures/my_project/config/templates/base/stacks.rb +0 -3
- data/spec/fixtures/my_project/params/my-stack.txt +0 -3
- data/spec/fixtures/my_project/templates/my-stack.yml +0 -0
- data/spec/lib/lono/new_spec.rb +0 -59
- data/spec/lib/lono/template/template_spec.rb +0 -104
- data/spec/lib/lono_spec.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 813d3d801fda95c8b91d3664909e105efa0233aa589324dd8480ff70d8364e83
|
4
|
+
data.tar.gz: 47425854afafa70350676c4e2a8af6b409c10f272d0547e679d45bec168ed0e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8c3bcc99b77b005f58d93d6893e44e74badf2bb86dc44dda78d0d364f003c4473a847ad7875ccbd9fac77177e884214dfdd0c546e80b0d5e9013a4652bacf2a
|
7
|
+
data.tar.gz: '049cebb1112d4ddacbe892965b615fffd93b0fc96ced048aae471d4798d42852f544f3a2ba51989ea711a88661cb3ccb76104afac4c5e204cf21efe52f7736b4'
|
data/.gitignore
CHANGED
@@ -1,10 +1,21 @@
|
|
1
|
-
.DS_Store
|
2
1
|
*.gem
|
2
|
+
*.rbc
|
3
3
|
.bundle
|
4
|
+
.config
|
5
|
+
.DS_Store
|
6
|
+
.yardoc
|
7
|
+
_yardoc
|
4
8
|
coverage
|
9
|
+
doc/
|
5
10
|
Gemfile.lock
|
6
|
-
|
7
|
-
|
11
|
+
InstalledFiles
|
12
|
+
lib/bundler/man
|
8
13
|
output
|
9
|
-
|
14
|
+
pkg
|
15
|
+
rdoc
|
10
16
|
spec/fixtures/my_project/templates/aws-waf-security-automations.yml
|
17
|
+
spec/project
|
18
|
+
spec/reports
|
19
|
+
test/tmp
|
20
|
+
test/version_tmp
|
21
|
+
tmp
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,20 @@
|
|
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
|
+
## [4.0.0]
|
7
|
+
- lono upgrade4 command
|
8
|
+
- simplified lono project structure
|
9
|
+
- app/scripts upload support and extract_scripts helper
|
10
|
+
- new settings.yml format: environment support, simplified s3_folder and aws_profiles options
|
11
|
+
- revamped starter projects
|
12
|
+
- added focus to lono import flow
|
13
|
+
- move lono summary up to top-level cli
|
14
|
+
- cli auto-completion support
|
15
|
+
- improved YAML parse error: shows error line immediately to user of output template
|
16
|
+
- better ERB template error rendering with render_me_pretty gem
|
17
|
+
- remove json support. focus on yaml.
|
18
|
+
- lono user_data command
|
19
|
+
|
6
20
|
## [3.5.0]
|
7
21
|
- Using Lono.root instead of scattered project_root parameters
|
8
22
|
- prefer use of Lono.env over LONO_ENV internally
|
@@ -65,7 +79,7 @@ This project *tries* to adhere to [Semantic Versioning](http://semver.org/), eve
|
|
65
79
|
- Format and Extension Detection
|
66
80
|
- Custom Helper Support
|
67
81
|
- Source Name Convention Support
|
68
|
-
-
|
82
|
+
- Setting File Support
|
69
83
|
|
70
84
|
## [2.1.0]
|
71
85
|
- improve instance_eval error when lono.rb errors, print out line of code and context
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
-
guard
|
2
|
-
watch(
|
1
|
+
guard "bundler", cmd: "bundle" do
|
2
|
+
watch("Gemfile")
|
3
|
+
watch(/^.+\.gemspec/)
|
3
4
|
end
|
4
5
|
|
5
|
-
guard
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
|
6
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
7
|
+
require "guard/rspec/dsl"
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
9
|
+
|
10
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/{LICENSE → LICENSE.txt}
RENAMED
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<img src="http://lono.cloud/img/logos/lono-logo.png" style="max-width: 300px" />
|
3
|
+
</div>
|
4
|
+
|
1
5
|
# Lono
|
2
6
|
|
3
7
|
[![Gem Version](https://badge.fury.io/rb/lono.png)](http://badge.fury.io/rb/lono)
|
@@ -11,14 +15,20 @@
|
|
11
15
|
[3]: https://codeclimate.com/repos/51d7f1407e00a4042c010ab4/badges/5273fe6cdb5a13e58554/gpa.png
|
12
16
|
[4]: https://codeclimate.com/repos/51d7f1407e00a4042c010ab4/feed
|
13
17
|
|
14
|
-
Lono is a tool to help you
|
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 provisions of the infrastructure.
|
15
19
|
|
16
|
-
* Lono generates CloudFormation templates based on ERB ruby templates in
|
17
|
-
* Lono takes simple env-like files
|
18
|
-
* Lono
|
20
|
+
* Lono generates CloudFormation templates based on ERB ruby templates in `yaml` format.
|
21
|
+
* Lono takes simple env-like files and generates the CloudFormation parameter files.
|
22
|
+
* Lono provides a simple CLI interface to launch the CloudFormation stacks.
|
19
23
|
|
20
24
|
See [lono.cloud](http://lono.cloud) for full lono documentation.
|
21
25
|
|
26
|
+
## Important
|
27
|
+
|
28
|
+
If you are on version 3, you can run `lono upgrade4` within your project to upgrade it to version 4. Refer to the [CHANGELOG](CHANGELOG.md).
|
29
|
+
|
30
|
+
## Blog Posts
|
31
|
+
|
22
32
|
These blog posts also cover lono:
|
23
33
|
|
24
34
|
* [Why Generate CloudFormation Templates with Lono](https://medium.com/boltops/why-generate-cloudformation-templates-with-lono-65b8ea5eb87d)
|
@@ -35,23 +45,21 @@ It only takes a couple of commands to start using lono.
|
|
35
45
|
gem install lono
|
36
46
|
lono new infra
|
37
47
|
cd infra
|
38
|
-
lono
|
39
|
-
|
48
|
+
lono import https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/EC2InstanceWithSecurityGroupSample.template --name ec2
|
49
|
+
# update the generated params file
|
50
|
+
lono cfn create ec2
|
40
51
|
```
|
41
|
-
|
42
|
-
This sets up a starter lono project called infra with example templates. You cd into the folder and call `lono cfn create` which automatically generates the CloudFormation template and parameter files to `output` and `output/params` and launches the stack.
|
43
|
-
|
44
52
|
![Lono flowchart](http://tongueroo.com/images/github-readmes/lono-flowchart.png "Lono flowchart")
|
45
53
|
|
46
|
-
###
|
54
|
+
### Lono Cfn Lifecycle Commands
|
47
55
|
|
48
|
-
Lono
|
56
|
+
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:
|
49
57
|
|
50
58
|
```
|
51
59
|
$ lono cfn create my-stack
|
52
60
|
```
|
53
61
|
|
54
|
-
The above command will generate files to `output/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:
|
62
|
+
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:
|
55
63
|
|
56
64
|
```
|
57
65
|
$ lono cfn create mystack-$(date +%Y%m%d%H%M%S) --template mystack --params mystack
|
data/Rakefile
CHANGED
data/{bin → exe}/lono
RENAMED
data/lib/lono.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require 'yaml'
|
3
|
-
require 'pp'
|
1
|
+
require 'active_support/core_ext/string'
|
4
2
|
require 'colorize'
|
5
3
|
require 'fileutils'
|
6
|
-
|
7
|
-
require '
|
4
|
+
require 'json'
|
5
|
+
require 'pp'
|
6
|
+
require 'render_me_pretty'
|
7
|
+
require 'yaml'
|
8
8
|
|
9
9
|
# vendor because need https://github.com/futurechimp/plissken/pull/6 to be merged
|
10
10
|
$:.unshift(File.expand_path("../../vendor/plissken/lib", __FILE__))
|
@@ -19,17 +19,20 @@ module Lono
|
|
19
19
|
autoload :Command, 'lono/command'
|
20
20
|
autoload :CLI, 'lono/cli'
|
21
21
|
autoload :New, 'lono/new'
|
22
|
+
autoload :Sequence, 'lono/sequence'
|
22
23
|
autoload :Template, 'lono/template'
|
23
24
|
autoload :Cfn, 'lono/cfn'
|
24
25
|
autoload :Param, 'lono/param'
|
25
26
|
autoload :Clean, 'lono/clean'
|
26
|
-
autoload :
|
27
|
+
autoload :Setting, 'lono/setting'
|
27
28
|
autoload :Importer, 'lono/importer'
|
28
29
|
autoload :Inspector, 'lono/inspector'
|
29
|
-
autoload :
|
30
|
+
autoload :Completion, 'lono/completion'
|
31
|
+
autoload :Completer, 'lono/completer'
|
30
32
|
autoload :Core, 'lono/core'
|
33
|
+
autoload :Upgrade4, 'lono/upgrade4'
|
34
|
+
autoload :Script, 'lono/script'
|
35
|
+
autoload :UserData, 'lono/user_data'
|
31
36
|
|
32
37
|
extend Core
|
33
38
|
end
|
34
|
-
|
35
|
-
Lono.setup!
|
data/lib/lono/cfn.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require "thor"
|
2
2
|
|
3
3
|
class Lono::Cfn < Lono::Command
|
4
|
-
autoload :
|
5
|
-
autoload :AwsServices, 'lono/cfn/aws_services'
|
4
|
+
autoload :AwsService, 'lono/cfn/aws_service'
|
6
5
|
autoload :Util, 'lono/cfn/util'
|
7
6
|
autoload :CLI, 'lono/cfn/cli'
|
8
7
|
autoload :Base, 'lono/cfn/base'
|
@@ -21,20 +20,19 @@ class Lono::Cfn < Lono::Command
|
|
21
20
|
class_option :template, desc: "override convention and specify the template file to use"
|
22
21
|
class_option :param, desc: "override convention and specify the param file to use"
|
23
22
|
class_option :lono, type: :boolean, desc: "invoke lono to generate CloudFormation templates", default: true
|
24
|
-
class_option :s3_upload, type: :boolean, desc: "uploads templates to s3 if s3.path detected", default: true
|
25
23
|
class_option :capabilities, type: :array, desc: "iam capabilities. Ex: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
|
26
24
|
class_option :iam, type: :boolean, desc: "Shortcut for common IAM capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
|
27
25
|
class_option :rollback, type: :boolean, desc: "rollback", default: true
|
28
26
|
|
29
27
|
desc "create STACK", "create a CloudFormation stack"
|
30
28
|
option :randomize_stack_name, type: :boolean, desc: "tack on random string at the end of the stack name", default: nil
|
31
|
-
long_desc Help.create
|
29
|
+
long_desc Lono::Help.text("cfn/create")
|
32
30
|
def create(name)
|
33
31
|
Create.new(name, options).run
|
34
32
|
end
|
35
33
|
|
36
34
|
desc "update STACK", "update a CloudFormation stack"
|
37
|
-
long_desc Help.update
|
35
|
+
long_desc Lono::Help.text("cfn/update")
|
38
36
|
option :change_set, type: :boolean, default: true, desc: "Uses generated change set to update the stack. If false, will perform normal update-stack."
|
39
37
|
option :diff, type: :boolean, default: true, desc: "Show diff of the source code template changes before continuing."
|
40
38
|
option :preview, type: :boolean, default: true, desc: "Show preview of the stack changes before continuing."
|
@@ -44,14 +42,14 @@ class Lono::Cfn < Lono::Command
|
|
44
42
|
end
|
45
43
|
|
46
44
|
desc "delete STACK", "delete a CloudFormation stack"
|
47
|
-
long_desc Help.delete
|
45
|
+
long_desc Lono::Help.text("cfn/delete")
|
48
46
|
option :sure, type: :boolean, desc: "Skips are you sure prompt"
|
49
47
|
def delete(name)
|
50
48
|
Delete.new(name, options).run
|
51
49
|
end
|
52
50
|
|
53
51
|
desc "preview STACK", "preview a CloudFormation stack update"
|
54
|
-
long_desc Help.preview
|
52
|
+
long_desc Lono::Help.text("cfn/preview")
|
55
53
|
option :keep, type: :boolean, desc: "keep the changeset instead of deleting it afterwards"
|
56
54
|
option :diff, type: :boolean, default: true, desc: "Show diff of the source code template changes also."
|
57
55
|
def preview(name)
|
@@ -60,13 +58,13 @@ class Lono::Cfn < Lono::Command
|
|
60
58
|
end
|
61
59
|
|
62
60
|
desc "diff STACK", "diff of newly generated template vs existing template in AWS"
|
63
|
-
long_desc Help.diff
|
61
|
+
long_desc Lono::Help.text("cfn/diff")
|
64
62
|
def diff(name)
|
65
63
|
Diff.new(name, options).run
|
66
64
|
end
|
67
65
|
|
68
66
|
desc "download STACK", "download CloudFormation template from existing stack"
|
69
|
-
long_desc Help.download
|
67
|
+
long_desc Lono::Help.text("cfn/download")
|
70
68
|
option :name, desc: "Name you want to save the template as. Default: existing stack name."
|
71
69
|
def download(stack_name)
|
72
70
|
Download.new(stack_name, options).run
|
data/lib/lono/cfn/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "lono"
|
2
2
|
|
3
3
|
class Lono::Cfn::Base
|
4
|
-
include Lono::Cfn::
|
4
|
+
include Lono::Cfn::AwsService
|
5
5
|
include Lono::Cfn::Util
|
6
6
|
|
7
7
|
attr_reader :randomize_stack_name
|
@@ -42,7 +42,7 @@ class Lono::Cfn::Base
|
|
42
42
|
puts " #{command_with_iam(capabilities)}"
|
43
43
|
|
44
44
|
puts "Please confirm (y/n)"
|
45
|
-
|
45
|
+
$stdin.gets
|
46
46
|
end
|
47
47
|
|
48
48
|
def command_with_iam(capabilities)
|
@@ -51,24 +51,35 @@ class Lono::Cfn::Base
|
|
51
51
|
|
52
52
|
def generate_all
|
53
53
|
if @options[:lono]
|
54
|
+
build_scripts
|
54
55
|
generate_templates
|
55
|
-
|
56
|
+
unless @options[:noop]
|
57
|
+
upload_scripts
|
58
|
+
upload_templates
|
59
|
+
end
|
56
60
|
end
|
57
61
|
params = generate_params(mute: @options[:mute_params])
|
58
62
|
check_for_errors
|
59
63
|
params
|
60
64
|
end
|
61
65
|
|
66
|
+
def build_scripts
|
67
|
+
Lono::Script::Build.new.run
|
68
|
+
end
|
69
|
+
|
62
70
|
def generate_templates
|
63
|
-
Lono::Template::DSL.new
|
71
|
+
Lono::Template::DSL.new.run
|
64
72
|
end
|
65
73
|
|
74
|
+
# only upload templates if s3_folder configured in settings
|
66
75
|
def upload_templates
|
67
|
-
|
68
|
-
|
69
|
-
return unless settings.s3_path
|
76
|
+
Lono::Template::Upload.new.run if s3_folder
|
77
|
+
end
|
70
78
|
|
71
|
-
|
79
|
+
# only upload templates if s3_folder configured in settings
|
80
|
+
def upload_scripts
|
81
|
+
return unless s3_folder
|
82
|
+
Lono::Script::Upload.new.run
|
72
83
|
end
|
73
84
|
|
74
85
|
def generate_params(options={})
|
@@ -97,13 +108,13 @@ class Lono::Cfn::Base
|
|
97
108
|
def check_files
|
98
109
|
errors, warns = [], []
|
99
110
|
unless File.exist?(@template_path)
|
100
|
-
|
111
|
+
errors << "Template file missing: could not find #{@template_path}"
|
101
112
|
end
|
102
113
|
# Examples:
|
103
114
|
# @param_path = params/prod/ecs.txt
|
104
115
|
# => output/params/prod/ecs.json
|
105
116
|
output_param_path = @param_path.sub(/\.txt/, '.json')
|
106
|
-
output_param_path = "#{Lono.
|
117
|
+
output_param_path = "#{Lono.config.output_path}/#{output_param_path}"
|
107
118
|
if @options[:param] && !File.exist?(output_param_path)
|
108
119
|
warns << "Parameters file missing: could not find #{output_param_path}"
|
109
120
|
end
|
@@ -117,7 +128,7 @@ class Lono::Cfn::Base
|
|
117
128
|
# Type - :param or :template
|
118
129
|
def get_source_path(path, type)
|
119
130
|
if path.nil?
|
120
|
-
|
131
|
+
convention_path(@stack_name, type) # default convention
|
121
132
|
else
|
122
133
|
# convention path based on the input from the user
|
123
134
|
convention_path(path, type)
|
@@ -127,36 +138,15 @@ class Lono::Cfn::Base
|
|
127
138
|
def convention_path(name, type)
|
128
139
|
path = case type
|
129
140
|
when :template
|
130
|
-
|
131
|
-
"#{Lono.root}/output/#{name}.#{format}"
|
141
|
+
"#{Lono.config.output_path}/templates/#{name}.yml"
|
132
142
|
when :param
|
133
|
-
"#{Lono.
|
143
|
+
"#{Lono.config.params_path}/#{Lono.env}/#{name}.txt"
|
134
144
|
else
|
135
145
|
raise "hell: dont come here"
|
136
146
|
end
|
137
147
|
path.sub(/^\.\//, '')
|
138
148
|
end
|
139
149
|
|
140
|
-
# Returns String with value of "yml" or "json".
|
141
|
-
def detect_format
|
142
|
-
formats = Dir.glob("#{Lono.root}/templates/**/*").
|
143
|
-
map { |path| path.sub(/\.erb$/, '') }.
|
144
|
-
map { |path| File.extname(path) }.
|
145
|
-
reject { |s| s.empty? }. # reject ""
|
146
|
-
select { |s| s.include?("yml") || s.include?("json") }.
|
147
|
-
uniq
|
148
|
-
if formats.size > 1
|
149
|
-
puts "ERROR: Detected multiple formats: #{formats.join(", ")}".colorize(:red)
|
150
|
-
puts "All the output files must use the same format. Either all json or all yml."
|
151
|
-
exit 1
|
152
|
-
elsif formats.size == 1
|
153
|
-
formats.first.sub(/^\./,'')
|
154
|
-
else
|
155
|
-
puts "WARN: Did not detect any template formats. Defaulting to yml. Please check the config and templates folders.".colorize(:yellow)
|
156
|
-
"yml" # default format
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
150
|
# All CloudFormation states listed here:
|
161
151
|
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html
|
162
152
|
def stack_status(stack_name)
|
@@ -164,15 +154,15 @@ class Lono::Cfn::Base
|
|
164
154
|
return false if @options[:noop]
|
165
155
|
|
166
156
|
resp = cfn.describe_stacks(stack_name: stack_name)
|
167
|
-
|
157
|
+
resp.stacks[0].stack_status
|
168
158
|
end
|
169
159
|
|
170
|
-
def
|
160
|
+
def exit_unless_updatable!(status)
|
171
161
|
return true if testing_update?
|
172
162
|
return false if @options[:noop]
|
173
163
|
|
174
164
|
unless status =~ /_COMPLETE$/
|
175
|
-
puts "Cannot create a change set for the stack because the #{@stack_name} is not in an updatable state. Stack status: #{status}"
|
165
|
+
puts "Cannot create a change set for the stack because the #{@stack_name} is not in an updatable state. Stack status: #{status}".colorize(:red)
|
176
166
|
quit(1)
|
177
167
|
end
|
178
168
|
end
|
@@ -202,7 +192,7 @@ class Lono::Cfn::Base
|
|
202
192
|
end
|
203
193
|
|
204
194
|
# otherwise use the settings preference
|
205
|
-
settings = Lono::
|
195
|
+
settings = Lono::Setting.new
|
206
196
|
settings.data['randomize_stack_name']
|
207
197
|
end
|
208
198
|
|
@@ -212,4 +202,17 @@ class Lono::Cfn::Base
|
|
212
202
|
["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
|
213
203
|
end
|
214
204
|
end
|
205
|
+
|
206
|
+
def show_parameters(params, meth=nil)
|
207
|
+
params = params.clone.compact
|
208
|
+
params[:template_body] = "Hidden due to size... View at: #{@template_path}"
|
209
|
+
to = meth || "AWS API"
|
210
|
+
puts "Parameters passed to #{to}:"
|
211
|
+
puts YAML.dump(params.deep_stringify_keys)
|
212
|
+
end
|
213
|
+
|
214
|
+
def s3_folder
|
215
|
+
setting = Lono::Setting.new
|
216
|
+
setting.s3_folder
|
217
|
+
end
|
215
218
|
end
|