lono 5.1.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/lono/cfn/util.rb CHANGED
@@ -1,21 +1,27 @@
1
- module Lono::Cfn::Util
2
- def are_you_sure?(stack_name, action)
3
- if @options[:sure]
4
- sure = 'y'
5
- else
6
- message = case action
7
- when :update
8
- "Are you sure you want to want to update the #{stack_name.color(:green)} stack with the changes? (y/N)"
9
- when :delete
10
- "Are you sure you want to want to delete the #{stack_name.color(:green)} stack? (y/N)"
1
+ class Lono::Cfn
2
+ module Util
3
+ def are_you_sure?(stack_name, action)
4
+ if @options[:sure]
5
+ sure = 'y'
6
+ else
7
+ message = case action
8
+ when :update
9
+ "Are you sure you want to want to update the #{stack_name.color(:green)} stack with the changes? (y/N)"
10
+ when :delete
11
+ "Are you sure you want to want to delete the #{stack_name.color(:green)} stack? (y/N)"
12
+ end
13
+ puts message
14
+ sure = $stdin.gets
15
+ end
16
+
17
+ unless sure =~ /^y/
18
+ puts "Whew! Exiting without running #{action}."
19
+ exit 0
11
20
  end
12
- puts message
13
- sure = $stdin.gets
14
21
  end
15
22
 
16
- unless sure =~ /^y/
17
- puts "Whew! Exiting without running #{action}."
18
- exit 0
23
+ def switch_current(stack_name)
24
+ Current.name!(stack_name)
19
25
  end
20
26
  end
21
27
  end
data/lib/lono/cfn.rb CHANGED
@@ -1,114 +1,121 @@
1
- require "thor"
2
- require "cfn/status"
1
+ module Lono
2
+ class Cfn < Command
3
+ class_option :verbose, type: :boolean
4
+ class_option :noop, type: :boolean
3
5
 
4
- class Lono::Cfn < Lono::Command
5
- class_option :verbose, type: :boolean
6
- class_option :noop, type: :boolean
6
+ base_options = Proc.new do
7
+ # common to create and update
8
+ option :blueprint, desc: "override convention and specify the template file to use"
9
+ option :template, desc: "override convention and specify the template file to use"
10
+ option :param, desc: "override convention and specify the param file to use"
11
+ option :lono, type: :boolean, desc: "invoke lono to generate CloudFormation templates", default: true
12
+ option :capabilities, type: :array, desc: "iam capabilities. Ex: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
13
+ option :iam, type: :boolean, desc: "Shortcut for common IAM capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
14
+ option :rollback, type: :boolean, desc: "rollback", default: true
15
+ option :tags, type: :hash, desc: "Tags for the stack. IE: name:api-web owner:bob"
16
+ end
17
+ wait_option = Proc.new do
18
+ option :wait, type: :boolean, desc: "Wait for stack operation to complete.", default: true
19
+ end
20
+ suffix_option = Proc.new do
21
+ option :suffix, desc: "Suffix for stack name."
22
+ end
23
+ update_options = Proc.new do
24
+ option :change_set, type: :boolean, default: true, desc: "Uses generated change set to update the stack. If false, will perform normal update-stack."
25
+ option :diff, type: :boolean, default: true, desc: "Show diff of the source code template changes before continuing."
26
+ option :preview, type: :boolean, default: true, desc: "Show preview of the stack changes before continuing."
27
+ option :sure, type: :boolean, desc: "Skips are you sure prompt"
28
+ end
7
29
 
8
- base_options = Proc.new do
9
- # common to create and update
10
- option :blueprint, desc: "override convention and specify the template file to use"
11
- option :template, desc: "override convention and specify the template file to use"
12
- option :param, desc: "override convention and specify the param file to use"
13
- option :lono, type: :boolean, desc: "invoke lono to generate CloudFormation templates", default: true
14
- option :capabilities, type: :array, desc: "iam capabilities. Ex: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
15
- option :iam, type: :boolean, desc: "Shortcut for common IAM capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
16
- option :rollback, type: :boolean, desc: "rollback", default: true
17
- option :tags, type: :hash, desc: "Tags for the stack. IE: name:api-web owner:bob"
18
- end
19
- wait_option = Proc.new do
20
- option :wait, type: :boolean, desc: "Wait for stack operation to complete.", default: true
21
- end
22
- suffix_option = Proc.new do
23
- option :suffix, desc: "Suffix for stack name."
24
- end
25
- update_options = Proc.new do
26
- option :change_set, type: :boolean, default: true, desc: "Uses generated change set to update the stack. If false, will perform normal update-stack."
27
- option :diff, type: :boolean, default: true, desc: "Show diff of the source code template changes before continuing."
28
- option :preview, type: :boolean, default: true, desc: "Show preview of the stack changes before continuing."
29
- option :sure, type: :boolean, desc: "Skips are you sure prompt"
30
- end
30
+ desc "create STACK", "Create a CloudFormation stack using the generated template."
31
+ base_options.call
32
+ suffix_option.call
33
+ wait_option.call
34
+ long_desc Lono::Help.text("cfn/create")
35
+ def create(stack_name)
36
+ Create.new(stack_name, options).run
37
+ end
31
38
 
32
- desc "create STACK", "Create a CloudFormation stack using the generated template."
33
- base_options.call
34
- suffix_option.call
35
- wait_option.call
36
- long_desc Lono::Help.text("cfn/create")
37
- def create(stack_name)
38
- Create.new(stack_name, options).run
39
- end
39
+ desc "update STACK", "Update a CloudFormation stack using the generated template."
40
+ long_desc Lono::Help.text("cfn/update")
41
+ base_options.call
42
+ update_options.call
43
+ wait_option.call
44
+ def update(stack_name=:current)
45
+ Update.new(stack_name, options).run
46
+ end
40
47
 
41
- desc "update STACK", "Update a CloudFormation stack using the generated template."
42
- long_desc Lono::Help.text("cfn/update")
43
- base_options.call
44
- update_options.call
45
- wait_option.call
46
- def update(stack_name=:current)
47
- Update.new(stack_name, options).run
48
- end
48
+ desc "deploy STACK", "Create or update a CloudFormation stack using the generated template."
49
+ long_desc Lono::Help.text("cfn/deploy")
50
+ base_options.call
51
+ suffix_option.call
52
+ update_options.call
53
+ wait_option.call
54
+ def deploy(stack_name=:current)
55
+ Deploy.new(stack_name, options).run
56
+ end
49
57
 
50
- desc "deploy STACK", "Create or update a CloudFormation stack using the generated template."
51
- long_desc Lono::Help.text("cfn/deploy")
52
- base_options.call
53
- suffix_option.call
54
- update_options.call
55
- wait_option.call
56
- def deploy(stack_name=:current)
57
- Deploy.new(stack_name, options).run
58
- end
58
+ desc "delete STACK", "Delete a CloudFormation stack."
59
+ long_desc Lono::Help.text("cfn/delete")
60
+ option :sure, type: :boolean, desc: "Skips are you sure prompt"
61
+ base_options.call
62
+ wait_option.call
63
+ def delete(stack_name=:current)
64
+ Delete.new(stack_name, options).run
65
+ end
59
66
 
60
- desc "delete STACK", "Delete a CloudFormation stack."
61
- long_desc Lono::Help.text("cfn/delete")
62
- option :sure, type: :boolean, desc: "Skips are you sure prompt"
63
- base_options.call
64
- wait_option.call
65
- def delete(stack_name=:current)
66
- Delete.new(stack_name, options).run
67
- end
67
+ desc "cancel STACK", "Cancel a CloudFormation stack."
68
+ long_desc Lono::Help.text("cfn/cancel")
69
+ option :sure, type: :boolean, desc: "Skips are you sure prompt"
70
+ wait_option.call
71
+ def cancel(stack_name=:current)
72
+ Cancel.new(stack_name, options).run
73
+ end
68
74
 
69
- desc "preview STACK", "Preview a CloudFormation stack update. This is similar to terraform's plan or puppet's dry-run mode."
70
- long_desc Lono::Help.text("cfn/preview")
71
- option :keep, type: :boolean, desc: "keep the changeset instead of deleting it afterwards"
72
- option :diff, type: :boolean, default: true, desc: "Show diff of the source code template changes also."
73
- base_options.call
74
- suffix_option.call
75
- def preview(stack_name=:current)
76
- Diff.new(stack_name, options).run if options[:diff]
77
- Preview.new(stack_name, options).run
78
- end
75
+ desc "preview STACK", "Preview a CloudFormation stack update. This is similar to terraform's plan or puppet's dry-run mode."
76
+ long_desc Lono::Help.text("cfn/preview")
77
+ option :keep, type: :boolean, desc: "keep the changeset instead of deleting it afterwards"
78
+ option :diff, type: :boolean, default: true, desc: "Show diff of the source code template changes also."
79
+ base_options.call
80
+ suffix_option.call
81
+ def preview(stack_name=:current)
82
+ Diff.new(stack_name, options).run if options[:diff]
83
+ Preview.new(stack_name, options).run
84
+ end
79
85
 
80
- desc "diff STACK", "Diff newly generated template vs existing template."
81
- long_desc Lono::Help.text("cfn/diff")
82
- base_options.call
83
- suffix_option.call
84
- def diff(stack_name=:current)
85
- Diff.new(stack_name, options).run
86
- end
86
+ desc "diff STACK", "Diff newly generated template vs existing template."
87
+ long_desc Lono::Help.text("cfn/diff")
88
+ base_options.call
89
+ suffix_option.call
90
+ def diff(stack_name=:current)
91
+ Diff.new(stack_name, options).run
92
+ end
87
93
 
88
- desc "download STACK", "Download CloudFormation template from existing stack."
89
- long_desc Lono::Help.text("cfn/download")
90
- option :name, desc: "Name you want to save the template as. Default: existing stack name."
91
- base_options.call
92
- suffix_option.call
93
- def download(stack_name=:current)
94
- Download.new(stack_name, options).run
95
- end
94
+ desc "download STACK", "Download CloudFormation template from existing stack."
95
+ long_desc Lono::Help.text("cfn/download")
96
+ option :name, desc: "Name you want to save the template as. Default: existing stack name."
97
+ base_options.call
98
+ suffix_option.call
99
+ def download(stack_name=:current)
100
+ Download.new(stack_name, options).run
101
+ end
96
102
 
97
- desc "current", "Current stack that you're working with."
98
- long_desc Lono::Help.text("cfn/current")
99
- option :rm, type: :boolean, desc: "Remove all current settings. Removes `.lono/current`"
100
- option :name, desc: "Current stack name."
101
- suffix_option.call
102
- def current
103
- Current.new(options).run
104
- end
103
+ desc "current", "Current stack that you're working with."
104
+ long_desc Lono::Help.text("cfn/current")
105
+ option :rm, type: :boolean, desc: "Remove all current settings. Removes `.lono/current`"
106
+ option :name, desc: "Current stack name."
107
+ suffix_option.call
108
+ def current
109
+ Current.new(options).run
110
+ end
105
111
 
106
- desc "status", "Shows the current status for the stack."
107
- long_desc Lono::Help.text("cfn/status")
108
- suffix_option.call
109
- def status(stack_name=:current)
110
- status = Lono::Cfn::Status.new(stack_name, options)
111
- success = status.run
112
- exit 3 unless success
112
+ desc "status", "Shows the current status for the stack."
113
+ long_desc Lono::Help.text("cfn/status")
114
+ suffix_option.call
115
+ def status(stack_name=:current)
116
+ status = Lono::Cfn::Status.new(stack_name, options)
117
+ success = status.run
118
+ exit 3 unless success
119
+ end
113
120
  end
114
- end
121
+ end
data/lib/lono/cli.rb CHANGED
@@ -48,13 +48,12 @@ module Lono
48
48
  Lono::Inspector::Graph.new(blueprint, template, options).run
49
49
  end
50
50
 
51
- desc "seed", "Seed blueprint configs with starter values."
52
- option :defaults, type: :boolean, desc: "Bypass prompt and use the blueprints configure default values."
51
+ desc "seed", "Generates starter configs for a blueprint."
52
+ long_desc Help.text("seed")
53
53
  option :param, desc: "override convention and specify the param file to use"
54
- option :seed, default: :convention, desc: "path to seed file to allow prompts bypass. yaml format."
55
54
  option :template, desc: "override convention and specify the template file to use"
56
55
  def seed(blueprint)
57
- Seed.new(blueprint, options).run
56
+ Seed.new(blueprint, options).create
58
57
  end
59
58
 
60
59
  desc "clean", "Removes `output` folder."
@@ -3,6 +3,7 @@ module Lono::Core
3
3
  PATHS = {
4
4
  definitions_path: "app/definitions",
5
5
  helpers_path: "app/helpers",
6
+ content_path: "app/content",
6
7
  partials_path: "app/partials",
7
8
  scripts_path: "app/scripts",
8
9
  templates_path: "app/templates",
@@ -0,0 +1,13 @@
1
+ ## Examples
2
+
3
+ $ lono cfn cancel demo
4
+ Canceling updates to demo.
5
+ Current stack status: UPDATE_IN_PROGRESS
6
+ Canceling stack update.
7
+ Waiting for stack to complete
8
+ 01:20:32PM UPDATE_ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack demo User Initiated
9
+ 01:20:44PM UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS AWS::CloudFormation::Stack demo
10
+ 01:20:44PM UPDATE_ROLLBACK_COMPLETE AWS::CloudFormation::Stack demo
11
+ Stack rolled back: UPDATE_ROLLBACK_COMPLETE
12
+ Time took for stack deployment: 15s.
13
+ $
@@ -0,0 +1,16 @@
1
+ ## Example
2
+
3
+ $ lono seed ecs-asg
4
+ Creating starter config files for ecs-asg
5
+ Starter params created: configs/ecs-asg/params/development.txt
6
+ $ cat configs/ecs-asg/params/development.txt
7
+ # Required parameters:
8
+ VpcId=vpc-111
9
+ Subnets=subnet-111,subnet-222,subnet-333
10
+ EcsCluster=development
11
+ # Optional parameters:
12
+ # InstanceType=m5.large
13
+ # KeyName=...
14
+ # SshLocation=...
15
+ # TagName=ecs-asg
16
+ $
@@ -1,7 +1,4 @@
1
- require "thor"
2
-
3
- class Lono::Inspector
4
- autoload :Base, 'lono/inspector/base'
5
- autoload :Summary, 'lono/inspector/summary'
6
- autoload :Graph, 'lono/inspector/graph'
1
+ module Lono
2
+ class Inspector
3
+ end
7
4
  end