lono 6.1.11 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/acceptance.sh +19 -3
- data/.gitignore +2 -2
- data/CHANGELOG.md +16 -1
- data/README.md +18 -20
- data/Rakefile +1 -0
- data/lib/lono.rb +7 -5
- data/lib/lono/abstract_base.rb +25 -0
- data/lib/lono/api/client.rb +30 -0
- data/lib/lono/api/proxy.rb +58 -0
- data/lib/lono/api/repos.rb +8 -0
- data/lib/lono/api/verify.rb +13 -0
- data/lib/lono/app_file/base.rb +4 -11
- data/lib/lono/app_file/build.rb +1 -1
- data/lib/lono/app_file/upload.rb +1 -4
- data/lib/lono/autoloader.rb +3 -1
- data/lib/lono/aws_services.rb +9 -9
- data/lib/lono/aws_services/helper.rb +14 -0
- data/lib/lono/aws_services/{util.rb → stack.rb} +1 -9
- data/lib/lono/aws_services/stack_set.rb +41 -0
- data/lib/lono/blueprint.rb +2 -2
- data/lib/lono/blueprint/configset/loader.rb +7 -0
- data/lib/lono/blueprint/helper.rb +8 -2
- data/lib/lono/blueprint/meta.rb +4 -12
- data/lib/lono/blueprint/new.rb +3 -3
- data/lib/lono/blueprint/root.rb +6 -26
- data/lib/lono/bundle.rb +54 -0
- data/lib/lono/cfn.rb +31 -75
- data/lib/lono/cfn/base.rb +39 -136
- data/lib/lono/cfn/cancel.rb +14 -9
- data/lib/lono/cfn/create.rb +15 -19
- data/lib/lono/cfn/delete.rb +9 -9
- data/lib/lono/cfn/deploy.rb +4 -4
- data/lib/lono/cfn/download.rb +27 -9
- data/lib/lono/cfn/opts.rb +80 -0
- data/lib/lono/cfn/preview/changeset.rb +23 -23
- data/lib/lono/cfn/preview/codediff.rb +5 -6
- data/lib/lono/cfn/preview/param.rb +10 -10
- data/lib/lono/cfn/rollback.rb +5 -5
- data/lib/lono/cfn/status.rb +0 -10
- data/lib/lono/cfn/update.rb +22 -27
- data/lib/lono/clean.rb +3 -3
- data/lib/lono/cli.rb +69 -34
- data/lib/lono/code.rb +22 -0
- data/lib/lono/command.rb +7 -0
- data/lib/lono/config_location.rb +6 -13
- data/lib/lono/configset.rb +9 -0
- data/lib/lono/configset/combiner.rb +128 -0
- data/lib/lono/configset/evaluate_file.rb +8 -0
- data/lib/lono/configset/list.rb +67 -0
- data/lib/lono/configset/loader.rb +98 -0
- data/lib/lono/configset/loader/dsl.rb +9 -0
- data/lib/lono/configset/materializer/final.rb +10 -0
- data/lib/lono/configset/materializer/gems_builder.rb +81 -0
- data/lib/lono/configset/materializer/jade.rb +15 -0
- data/lib/lono/configset/materializer/source.rb +54 -0
- data/lib/lono/configset/meta.rb +19 -0
- data/lib/lono/configset/meta/dsl.rb +12 -0
- data/lib/lono/configset/new.rb +84 -0
- data/lib/lono/configset/preparer.rb +44 -0
- data/lib/lono/configset/register/base.rb +121 -0
- data/lib/lono/configset/register/blueprint.rb +16 -0
- data/lib/lono/configset/register/dsl.rb +15 -0
- data/lib/lono/configset/register/project.rb +12 -0
- data/lib/lono/configset/registry.rb +34 -0
- data/lib/lono/configset/resolver.rb +42 -0
- data/lib/lono/conventions.rb +18 -7
- data/lib/lono/core.rb +16 -20
- data/lib/lono/default/settings.yml +2 -3
- data/lib/lono/ext/bundler.rb +7 -0
- data/lib/lono/file_uploader.rb +8 -5
- data/lib/lono/finder/base.rb +140 -0
- data/lib/lono/finder/blueprint.rb +11 -0
- data/lib/lono/finder/blueprint/configset.rb +17 -0
- data/lib/lono/finder/configset.rb +11 -0
- data/lib/lono/generate.rb +93 -0
- data/lib/lono/help/blueprint/new.md +0 -1
- data/lib/lono/help/cfn/delete.md +1 -1
- data/lib/lono/help/cfn/deploy.md +5 -76
- data/lib/lono/help/cfn/status.md +0 -4
- data/lib/lono/help/cfn/update.md +1 -1
- data/lib/lono/help/code/convert.md +51 -0
- data/lib/lono/help/code/import.md +30 -0
- data/lib/lono/help/configsets.md +24 -0
- data/lib/lono/help/generate.md +4 -4
- data/lib/lono/help/new.md +1 -2
- data/lib/lono/help/sets/delete.md +8 -0
- data/lib/lono/help/sets/deploy.md +76 -0
- data/lib/lono/help/sets/instances/delete.md +21 -0
- data/lib/lono/help/sets/instances/list.md +14 -0
- data/lib/lono/help/sets/instances/status.md +15 -0
- data/lib/lono/help/sets/instances/sync.md +88 -0
- data/lib/lono/help/sets/status.md +23 -0
- data/lib/lono/help/upgrade.md +1 -0
- data/lib/lono/importer.rb +22 -0
- data/lib/lono/importer/base.rb +59 -0
- data/lib/lono/importer/converter.rb +19 -0
- data/lib/lono/importer/download.rb +46 -0
- data/lib/lono/importer/dsl.rb +36 -0
- data/lib/lono/importer/erb.rb +31 -0
- data/lib/lono/importer/params.rb +56 -0
- data/lib/lono/importer/service/coder.rb +81 -0
- data/lib/lono/inspector/base.rb +12 -22
- data/lib/lono/inspector/graph.rb +1 -1
- data/lib/lono/inspector/summary.rb +41 -17
- data/lib/lono/jade.rb +103 -0
- data/lib/lono/jade/circular.rb +26 -0
- data/lib/lono/jadespec.rb +41 -0
- data/lib/lono/new.rb +2 -2
- data/lib/lono/opts.rb +43 -0
- data/lib/lono/output/template.rb +48 -0
- data/lib/lono/param.rb +3 -5
- data/lib/lono/param/generator.rb +13 -33
- data/lib/lono/pro.rb +15 -0
- data/lib/lono/pro/base.rb +16 -0
- data/lib/lono/pro/repo.rb +27 -0
- data/lib/lono/project_checker.rb +4 -29
- data/lib/lono/registration.rb +15 -0
- data/lib/lono/registration/base.rb +37 -0
- data/lib/lono/registration/check.rb +15 -0
- data/lib/lono/registration/temp.rb +60 -0
- data/lib/lono/registration/user.rb +54 -0
- data/lib/lono/script/base.rb +1 -10
- data/lib/lono/script/upload.rb +2 -12
- data/lib/lono/seed.rb +2 -11
- data/lib/lono/seed/base.rb +55 -110
- data/lib/lono/sets.rb +38 -0
- data/lib/lono/sets/base.rb +45 -0
- data/lib/lono/sets/create.rb +30 -0
- data/lib/lono/sets/delete.rb +47 -0
- data/lib/lono/sets/deploy.rb +11 -0
- data/lib/lono/sets/instances.rb +33 -0
- data/lib/lono/sets/instances/base.rb +30 -0
- data/lib/lono/sets/instances/delete.rb +69 -0
- data/lib/lono/sets/instances/list.rb +13 -0
- data/lib/lono/sets/instances/opts.rb +29 -0
- data/lib/lono/sets/instances/status.rb +12 -0
- data/lib/lono/sets/instances/sync.rb +182 -0
- data/lib/lono/sets/list.rb +35 -0
- data/lib/lono/sets/opts.rb +18 -0
- data/lib/lono/sets/preview/codediff.rb +35 -0
- data/lib/lono/sets/preview/param.rb +32 -0
- data/lib/lono/sets/status.rb +116 -0
- data/lib/lono/sets/status/instance.rb +20 -0
- data/lib/lono/sets/status/instance/base.rb +120 -0
- data/lib/lono/sets/status/instance/completed.rb +35 -0
- data/lib/lono/sets/status/instance/deleted.rb +32 -0
- data/lib/lono/sets/status/instance/show.rb +7 -0
- data/lib/lono/sets/status/instances.rb +111 -0
- data/lib/lono/sets/summarize.rb +20 -0
- data/lib/lono/sets/time_spent.rb +11 -0
- data/lib/lono/sets/update.rb +81 -0
- data/lib/lono/template.rb +5 -7
- data/lib/lono/template/configset_injector.rb +50 -0
- data/lib/lono/template/context.rb +4 -4
- data/lib/lono/template/context/loader.rb +4 -16
- data/lib/lono/template/evaluate.rb +2 -1
- data/lib/lono/template/generator.rb +17 -15
- data/lib/lono/template/helper.rb +7 -7
- data/lib/lono/template/post_processor.rb +2 -12
- data/lib/lono/template/strategy/base.rb +4 -0
- data/lib/lono/template/{dsl.rb → strategy/dsl.rb} +4 -6
- data/lib/lono/template/{dsl → strategy/dsl}/builder.rb +11 -15
- data/lib/lono/template/{dsl → strategy/dsl}/builder/fn.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/helpers.rb +11 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/core_helper.rb +14 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb +48 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/lookup_helper.rb +27 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/s3_helper.rb +13 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb +39 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/base.rb +6 -17
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/condition.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/section/extensions.rb +9 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/mapping.rb +1 -1
- data/lib/lono/template/{dsl/builder/section_methods.rb → strategy/dsl/builder/section/methods.rb} +9 -2
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/output.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/section/parameter.rb +69 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/resource.rb +1 -1
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/resource/property_mover.rb +1 -1
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/section.rb +1 -1
- data/lib/lono/template/{dsl → strategy/dsl}/builder/squeezer.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/stringify.rb +15 -0
- data/lib/lono/template/{dsl → strategy/dsl}/builder/syntax.rb +3 -2
- data/lib/lono/template/strategy/dsl/finalizer.rb +12 -0
- data/lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb +56 -0
- data/lib/lono/template/{erb.rb → strategy/erb.rb} +5 -5
- data/lib/lono/template/strategy/source.rb +8 -0
- data/lib/lono/template/template.rb +1 -1
- data/lib/lono/template/upload.rb +4 -9
- data/lib/lono/template/util.rb +0 -40
- data/lib/lono/upgrade.rb +12 -10
- data/lib/lono/user_data.rb +4 -4
- data/lib/lono/utils/pretty_time.rb +14 -0
- data/lib/lono/utils/sure.rb +23 -0
- data/lib/lono/version.rb +1 -1
- data/lib/lono/yamler/loader.rb +52 -0
- data/lib/lono/yamler/validator.rb +51 -0
- data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +4 -0
- data/lib/templates/blueprint/README.md.tt +1 -1
- data/lib/templates/blueprint/seed/configs.rb +2 -2
- data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +17 -18
- data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +63 -4
- data/lib/templates/configset/%configset_name%.gemspec.tt +41 -0
- data/lib/templates/configset/.gitignore +11 -0
- data/lib/templates/configset/CHANGELOG.md +7 -0
- data/lib/templates/configset/Gemfile +4 -0
- data/lib/templates/configset/README.md.tt +3 -0
- data/lib/templates/configset/Rakefile.tt +9 -0
- data/lib/templates/configset/lib/configset.yml +20 -0
- data/lib/templates/skeleton/.gitignore +1 -0
- data/lib/templates/skeleton/Gemfile +0 -1
- data/lib/templates/skeleton/README.md +4 -4
- data/lib/templates/skeleton/configs/settings.yml +1 -1
- data/lono.gemspec +1 -4
- metadata +146 -79
- data/Guardfile +0 -19
- data/lib/lono/app_file.rb +0 -5
- data/lib/lono/blueprint/find.rb +0 -90
- data/lib/lono/blueprint/info.rb +0 -10
- data/lib/lono/blueprint/list.rb +0 -14
- data/lib/lono/cfn/current.rb +0 -95
- data/lib/lono/cfn/preview.rb +0 -4
- data/lib/lono/cfn/suffix.rb +0 -67
- data/lib/lono/cfn/util.rb +0 -27
- data/lib/lono/help/cfn/current.md +0 -18
- data/lib/lono/help/upgrade4.md +0 -25
- data/lib/lono/inspector.rb +0 -4
- data/lib/lono/output_template.rb +0 -35
- data/lib/lono/template/base.rb +0 -13
- data/lib/lono/template/dsl/builder/helpers.rb +0 -8
- data/lib/lono/template/dsl/builder/helpers/core_helper.rb +0 -107
- data/lib/lono/template/dsl/builder/helpers/param_helper.rb +0 -61
- data/lib/lono/template/dsl/builder/parameter.rb +0 -39
- data/lib/lono/upgrade/upgrade4.rb +0 -175
- data/lib/lono/upgrade/upgrade42.rb +0 -36
- data/lib/lono/upgrade/upgrade5.rb +0 -55
- data/lib/templates/blueprint/.meta/config.yml.tt +0 -4
- data/lib/templates/skeleton/Guardfile +0 -12
- data/lib/templates/upgrade5/blueprints/main/.lono/config.yml +0 -3
- data/lib/templates/upgrade5/blueprints/main/.meta/config.yml +0 -3
data/lib/lono/cfn/cancel.rb
CHANGED
@@ -1,27 +1,32 @@
|
|
1
1
|
class Lono::Cfn
|
2
2
|
class Cancel
|
3
3
|
include Lono::AwsServices
|
4
|
-
include
|
4
|
+
include Lono::Utils::Sure
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@stack_name = switch_current(stack_name)
|
6
|
+
def initialize(options={})
|
8
7
|
@options = options
|
8
|
+
@stack = options[:stack]
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
|
12
|
+
if @options[:noop]
|
13
|
+
puts "NOOP Canceling #{@stack} stack"
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
stack = find_stack(@stack)
|
13
18
|
unless stack
|
14
|
-
puts "The '#{@
|
19
|
+
puts "The '#{@stack}' stack does not exist. Unable to cancel"
|
15
20
|
exit 1
|
16
21
|
end
|
17
22
|
|
18
|
-
puts "Canceling updates to #{@
|
23
|
+
puts "Canceling updates to #{@stack}."
|
19
24
|
puts "Current stack status: #{stack.stack_status}"
|
20
25
|
if stack.stack_status == "CREATE_IN_PROGRESS"
|
21
|
-
cfn.delete_stack(stack_name: @
|
26
|
+
cfn.delete_stack(stack_name: @stack)
|
22
27
|
puts "Canceling stack creation."
|
23
28
|
elsif stack.stack_status == "UPDATE_IN_PROGRESS"
|
24
|
-
cfn.cancel_update_stack(stack_name: @
|
29
|
+
cfn.cancel_update_stack(stack_name: @stack)
|
25
30
|
puts "Canceling stack update."
|
26
31
|
status.wait if @options[:wait]
|
27
32
|
else
|
@@ -30,7 +35,7 @@ class Lono::Cfn
|
|
30
35
|
end
|
31
36
|
|
32
37
|
def status
|
33
|
-
@status ||= Status.new(@
|
38
|
+
@status ||= Status.new(@stack)
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
data/lib/lono/cfn/create.rb
CHANGED
@@ -2,14 +2,10 @@ require "yaml"
|
|
2
2
|
|
3
3
|
class Lono::Cfn
|
4
4
|
class Create < Base
|
5
|
-
#
|
6
|
-
def save_stack(params)
|
7
|
-
create_stack(params)
|
8
|
-
end
|
9
|
-
|
5
|
+
# save is the interface method
|
10
6
|
# aws cloudformation create-stack --stack-name prod-hi-123456789 --parameters file://output/params/prod-hi-123456789.json --template-body file://output/prod-hi.json
|
11
|
-
def
|
12
|
-
message = "Creating #{@
|
7
|
+
def save(parameters)
|
8
|
+
message = "Creating #{@stack.color(:green)} stack."
|
13
9
|
if @options[:noop]
|
14
10
|
puts "NOOP #{message}"
|
15
11
|
return
|
@@ -17,28 +13,28 @@ class Lono::Cfn
|
|
17
13
|
|
18
14
|
delete_rollback_stack
|
19
15
|
|
20
|
-
if stack_exists?(@
|
21
|
-
puts "Cannot create #{@
|
16
|
+
if stack_exists?(@stack)
|
17
|
+
puts "Cannot create #{@stack.color(:green)} stack because it already exists.".color(:red)
|
22
18
|
return
|
23
19
|
end
|
24
20
|
|
25
|
-
unless File.exist?(
|
26
|
-
puts "Cannot create #{@
|
21
|
+
unless File.exist?(template_path)
|
22
|
+
puts "Cannot create #{@stack.color(:green)} template not found: #{template_path}."
|
27
23
|
return
|
28
24
|
end
|
29
25
|
|
30
|
-
|
31
|
-
stack_name: @
|
32
|
-
parameters:
|
26
|
+
options = {
|
27
|
+
stack_name: @stack,
|
28
|
+
parameters: parameters,
|
33
29
|
capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
|
34
30
|
disable_rollback: !@options[:rollback],
|
35
31
|
}
|
36
|
-
|
37
|
-
|
32
|
+
options[:tags] = tags unless tags.empty?
|
33
|
+
set_template_url!(options)
|
38
34
|
|
39
|
-
|
40
|
-
cfn.create_stack(
|
35
|
+
show_options(options, "cfn.create_stack")
|
36
|
+
cfn.create_stack(options) # TODO: COMMENT OUT FOR TESTING
|
41
37
|
puts message unless @options[:mute]
|
42
38
|
end
|
43
39
|
end
|
44
|
-
end
|
40
|
+
end
|
data/lib/lono/cfn/delete.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
class Lono::Cfn
|
2
2
|
class Delete
|
3
3
|
include Lono::AwsServices
|
4
|
-
include
|
4
|
+
include Lono::Utils::Sure
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@stack_name = switch_current(stack_name)
|
6
|
+
def initialize(options={})
|
8
7
|
@options = options
|
8
|
+
@stack = options.delete(:stack)
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
message = "Deleting #{@
|
12
|
+
message = "Deleting #{@stack} stack."
|
13
13
|
if @options[:noop]
|
14
14
|
puts "NOOP #{message}"
|
15
15
|
else
|
16
|
-
|
16
|
+
sure?("Are you sure you want to delete the #{@stack} stack?")
|
17
17
|
|
18
|
-
if stack_exists?(@
|
19
|
-
cfn.delete_stack(stack_name: @
|
18
|
+
if stack_exists?(@stack)
|
19
|
+
cfn.delete_stack(stack_name: @stack)
|
20
20
|
puts message
|
21
21
|
else
|
22
|
-
puts "#{@
|
22
|
+
puts "#{@stack.inspect} stack does not exist".color(:red)
|
23
23
|
return
|
24
24
|
end
|
25
25
|
end
|
@@ -32,7 +32,7 @@ class Lono::Cfn
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def status
|
35
|
-
@status ||= Status.new(@
|
35
|
+
@status ||= Status.new(@stack)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/lono/cfn/deploy.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
class Lono::Cfn
|
2
2
|
class Deploy < Base
|
3
|
-
def
|
4
|
-
if stack_exists?(@
|
5
|
-
Update.new(@
|
3
|
+
def save(parameters)
|
4
|
+
if stack_exists?(@stack)
|
5
|
+
Update.new(@options).save(parameters)
|
6
6
|
else
|
7
|
-
Create.new(@
|
7
|
+
Create.new(@options).save(parameters)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/lib/lono/cfn/download.rb
CHANGED
@@ -1,22 +1,37 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'open-uri'
|
2
3
|
|
3
4
|
class Lono::Cfn
|
4
|
-
class Download <
|
5
|
+
class Download < Lono::AbstractBase
|
6
|
+
include Lono::AwsServices
|
7
|
+
|
5
8
|
def run
|
6
|
-
|
9
|
+
pretty_path = download_path.sub("#{Lono.root}/", '')
|
10
|
+
puts "Downloading template to: #{pretty_path}"
|
7
11
|
return if @options[:noop]
|
8
12
|
download_template
|
9
13
|
end
|
10
14
|
|
11
15
|
def download_template
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
)
|
16
|
-
body = convert_to_yaml(resp.template_body)
|
16
|
+
body = download_stack
|
17
|
+
body = convert_to_yaml(body)
|
18
|
+
FileUtils.mkdir_p(File.dirname(download_path))
|
17
19
|
IO.write(download_path, body)
|
18
20
|
end
|
19
21
|
|
22
|
+
def download_stack
|
23
|
+
source = @options[:source]
|
24
|
+
if source
|
25
|
+
open(source).read # url or file
|
26
|
+
else
|
27
|
+
resp = cfn.get_template(
|
28
|
+
stack_name: @stack,
|
29
|
+
template_stage: "Original"
|
30
|
+
)
|
31
|
+
resp.template_body
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
20
35
|
def convert_to_yaml(body)
|
21
36
|
json?(body) ? YAML.dump(JSON.parse(body)) : body
|
22
37
|
end
|
@@ -26,8 +41,11 @@ class Lono::Cfn
|
|
26
41
|
end
|
27
42
|
|
28
43
|
def download_path
|
29
|
-
|
30
|
-
|
44
|
+
"#{Lono.config.output_path}/#{@blueprint}/templates/#{@blueprint}.yml"
|
45
|
+
end
|
46
|
+
|
47
|
+
def name
|
48
|
+
@options[:name] || @stack
|
31
49
|
end
|
32
50
|
end
|
33
51
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
class Lono::Cfn
|
2
|
+
class Opts < Lono::Opts
|
3
|
+
def create
|
4
|
+
base_options
|
5
|
+
wait_options
|
6
|
+
end
|
7
|
+
|
8
|
+
def update
|
9
|
+
base_options
|
10
|
+
update_options
|
11
|
+
wait_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def deploy
|
15
|
+
update
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete
|
19
|
+
wait_options
|
20
|
+
end
|
21
|
+
|
22
|
+
def cancel
|
23
|
+
wait_options
|
24
|
+
end
|
25
|
+
|
26
|
+
def preview
|
27
|
+
base_options
|
28
|
+
update_options
|
29
|
+
with_cli_scope do
|
30
|
+
option :keep, type: :boolean, desc: "keep the changeset instead of deleting it afterwards"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def download
|
35
|
+
base_options
|
36
|
+
with_cli_scope do
|
37
|
+
option :name, desc: "Name you want to save the template as. Default: existing stack name."
|
38
|
+
option :source, desc: "url or path to file with template"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Lono::Cfn and Lono::Sets
|
43
|
+
def base_options(rollback: true)
|
44
|
+
with_cli_scope do
|
45
|
+
if rollback
|
46
|
+
option :rollback, type: :boolean, desc: "rollback", default: true
|
47
|
+
end
|
48
|
+
# common to Lono::Cfn and Lono::Sets
|
49
|
+
option :source, desc: "url or path to file with template"
|
50
|
+
option :blueprint, desc: "override convention and specify the template file to use"
|
51
|
+
option :capabilities, type: :array, desc: "iam capabilities. Ex: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
|
52
|
+
option :config, aliases: "c", desc: "override convention and specify both the param and variable file to use"
|
53
|
+
option :iam, type: :boolean, desc: "Shortcut for common IAM capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
|
54
|
+
option :param, aliases: "p", desc: "override convention and specify the param file to use"
|
55
|
+
option :tags, type: :hash, desc: "Tags for the stack. IE: Name:api-web Owner:bob"
|
56
|
+
option :template, desc: "override convention and specify the template file to use"
|
57
|
+
option :variable, aliases: "v", desc: "override convention and specify the variable file to use"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def wait_options
|
62
|
+
with_cli_scope do
|
63
|
+
option :wait, type: :boolean, desc: "Wait for stack operation to complete.", default: true
|
64
|
+
option :sure, type: :boolean, desc: "Skip are you sure prompt" # moved to base but used by commands like `lono cfn delete` also. Just keep here.
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def update_options(change_set: true)
|
69
|
+
with_cli_scope do
|
70
|
+
if change_set
|
71
|
+
option :change_set, type: :boolean, default: true, desc: "Uses generated change set to update the stack. If false, will perform normal update-stack."
|
72
|
+
option :changeset_preview, type: :boolean, default: true, desc: "Show ChangeSet changes preview."
|
73
|
+
end
|
74
|
+
# common to Lono::Cfn and Lono::Sets
|
75
|
+
option :codediff_preview, type: :boolean, default: true, desc: "Show codediff changes preview."
|
76
|
+
option :param_preview, type: :boolean, default: true, desc: "Show parameter diff preview."
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -5,39 +5,39 @@ module Lono::Cfn::Preview
|
|
5
5
|
puts "Changeset Preview:".color(:green)
|
6
6
|
|
7
7
|
if @options[:noop]
|
8
|
-
puts "NOOP CloudFormation preview for #{@
|
8
|
+
puts "NOOP CloudFormation preview for #{@stack} update"
|
9
9
|
return
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
success = preview_change_set(
|
12
|
+
parameters = generate_all
|
13
|
+
success = preview_change_set(parameters)
|
14
14
|
delete_change_set if success && !@options[:keep] # Clean up and delete the change set
|
15
15
|
end
|
16
16
|
|
17
|
-
def preview_change_set(
|
18
|
-
success = create_change_set(
|
17
|
+
def preview_change_set(parameters)
|
18
|
+
success = create_change_set(parameters)
|
19
19
|
display_change_set if success
|
20
20
|
end
|
21
21
|
|
22
|
-
def create_change_set(
|
23
|
-
unless stack_exists?(@
|
24
|
-
puts "WARN: Cannot create a change set for the stack because the #{@
|
22
|
+
def create_change_set(parameters)
|
23
|
+
unless stack_exists?(@stack)
|
24
|
+
puts "WARN: Cannot create a change set for the stack because the #{@stack} does not exists.".color(:yellow)
|
25
25
|
return false
|
26
26
|
end
|
27
|
-
exit_unless_updatable!
|
27
|
+
exit_unless_updatable!
|
28
28
|
|
29
|
-
|
29
|
+
options = {
|
30
30
|
change_set_name: change_set_name,
|
31
|
-
stack_name: @
|
32
|
-
parameters:
|
31
|
+
stack_name: @stack,
|
32
|
+
parameters: parameters,
|
33
33
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
options[:tags] = tags unless tags.empty?
|
35
|
+
set_template_url!(options)
|
36
|
+
show_options(options, "cfn.create_change_set")
|
37
37
|
begin
|
38
|
-
# Tricky for preview need to set capabilities so that it gets updated. For Base#run
|
39
|
-
|
40
|
-
cfn.create_change_set(
|
38
|
+
# Tricky for preview need to set capabilities so that it gets updated. For Base#run save within the begin block already.
|
39
|
+
options[:capabilities] = capabilities # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
|
40
|
+
cfn.create_change_set(options)
|
41
41
|
rescue Aws::CloudFormation::Errors::InsufficientCapabilitiesException => e
|
42
42
|
# If coming from cfn_preview_command automatically add iam capabilities
|
43
43
|
cfn_preview_command = ARGV.join(" ").include?("cfn preview")
|
@@ -83,7 +83,7 @@ module Lono::Cfn::Preview
|
|
83
83
|
|
84
84
|
case change_set.status
|
85
85
|
when "CREATE_COMPLETE"
|
86
|
-
puts "CloudFormation preview for '#{@
|
86
|
+
puts "CloudFormation preview for '#{@stack}' stack update. Changes:"
|
87
87
|
changes = change_set.changes.sort_by do |change|
|
88
88
|
change["resource_change"]["action"]
|
89
89
|
end
|
@@ -91,7 +91,7 @@ module Lono::Cfn::Preview
|
|
91
91
|
display_change(change)
|
92
92
|
end
|
93
93
|
when "FAILED"
|
94
|
-
puts "WARN: Fail to create a CloudFormation preview for '#{@
|
94
|
+
puts "WARN: Fail to create a CloudFormation preview for '#{@stack}' stack update. Reason:".color(:yellow)
|
95
95
|
puts change_set.status_reason
|
96
96
|
quit(0)
|
97
97
|
else
|
@@ -102,14 +102,14 @@ module Lono::Cfn::Preview
|
|
102
102
|
def delete_change_set
|
103
103
|
cfn.delete_change_set(
|
104
104
|
change_set_name: change_set_name,
|
105
|
-
stack_name: @
|
105
|
+
stack_name: @stack
|
106
106
|
)
|
107
107
|
end
|
108
108
|
|
109
109
|
def execute_change_set
|
110
110
|
cfn.execute_change_set(
|
111
111
|
change_set_name: change_set_name,
|
112
|
-
stack_name: @
|
112
|
+
stack_name: @stack
|
113
113
|
)
|
114
114
|
end
|
115
115
|
|
@@ -160,7 +160,7 @@ module Lono::Cfn::Preview
|
|
160
160
|
def describe_change_set
|
161
161
|
cfn.describe_change_set(
|
162
162
|
change_set_name: change_set_name,
|
163
|
-
stack_name: @
|
163
|
+
stack_name: @stack
|
164
164
|
)
|
165
165
|
end
|
166
166
|
end
|
@@ -6,8 +6,8 @@ module Lono::Cfn::Preview
|
|
6
6
|
def run
|
7
7
|
puts "Code Diff Preview:".color(:green)
|
8
8
|
|
9
|
-
unless stack_exists?(@
|
10
|
-
puts "WARN: Cannot create a diff for the stack because the #{@
|
9
|
+
unless stack_exists?(@stack)
|
10
|
+
puts "WARN: Cannot create a diff for the stack because the #{@stack} does not exists.".color(:yellow)
|
11
11
|
return
|
12
12
|
end
|
13
13
|
|
@@ -23,20 +23,19 @@ module Lono::Cfn::Preview
|
|
23
23
|
|
24
24
|
def download_existing_cfn_template
|
25
25
|
resp = cfn.get_template(
|
26
|
-
stack_name: @
|
26
|
+
stack_name: @stack,
|
27
27
|
template_stage: "Original"
|
28
28
|
)
|
29
|
-
resp.template_body
|
30
29
|
IO.write(existing_template_path, resp.template_body)
|
31
30
|
end
|
32
31
|
|
33
32
|
# for clarity
|
34
33
|
def new_cfn_template
|
35
|
-
|
34
|
+
template_path
|
36
35
|
end
|
37
36
|
|
38
37
|
def existing_template_path
|
39
|
-
"/tmp/
|
38
|
+
"/tmp/existing_stack.yml"
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
@@ -7,12 +7,12 @@ module Lono::Cfn::Preview
|
|
7
7
|
include Lono::AwsServices
|
8
8
|
|
9
9
|
def run
|
10
|
-
return unless stack_exists?(@
|
10
|
+
return unless stack_exists?(@stack)
|
11
11
|
|
12
|
-
|
12
|
+
generated_parameters # eager call generated_parameters so its output is above Parameter Diff Preview
|
13
13
|
puts "Parameter Diff Preview:".color(:green)
|
14
14
|
if @options[:noop]
|
15
|
-
puts "NOOP CloudFormation parameters preview for #{@
|
15
|
+
puts "NOOP CloudFormation parameters preview for #{@stack} update"
|
16
16
|
return
|
17
17
|
end
|
18
18
|
|
@@ -30,7 +30,7 @@ module Lono::Cfn::Preview
|
|
30
30
|
memoize :existing_params
|
31
31
|
|
32
32
|
def new_params
|
33
|
-
params = optional_params.merge(
|
33
|
+
params = optional_params.merge(generated_parameters)
|
34
34
|
subtract(params, noecho_params)
|
35
35
|
end
|
36
36
|
|
@@ -42,11 +42,11 @@ module Lono::Cfn::Preview
|
|
42
42
|
Hash[hash.sort_by {|k,v| k}]
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
47
|
-
normalize(
|
45
|
+
def generated_parameters
|
46
|
+
parameters = generate_all
|
47
|
+
normalize(parameters)
|
48
48
|
end
|
49
|
-
memoize :
|
49
|
+
memoize :generated_parameters
|
50
50
|
|
51
51
|
def optional_params
|
52
52
|
# normalizing to simple Hash
|
@@ -62,7 +62,7 @@ module Lono::Cfn::Preview
|
|
62
62
|
memoize :noecho_params
|
63
63
|
|
64
64
|
def stack_parameters
|
65
|
-
resp = cfn.describe_stacks(stack_name: @
|
65
|
+
resp = cfn.describe_stacks(stack_name: @stack)
|
66
66
|
stack = resp.stacks.first
|
67
67
|
stack.parameters
|
68
68
|
end
|
@@ -70,7 +70,7 @@ module Lono::Cfn::Preview
|
|
70
70
|
|
71
71
|
private
|
72
72
|
def output_template
|
73
|
-
Lono::
|
73
|
+
Lono::Output::Template.new(@blueprint, @template)
|
74
74
|
end
|
75
75
|
memoize :output_template
|
76
76
|
|