cfndk 0.0.7 → 0.1.2
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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +79 -0
- data/.gitignore +1 -1
- data/.rspec +2 -0
- data/.rspec_parallel +6 -0
- data/.simplecov +9 -0
- data/Gemfile +11 -1
- data/Gemfile.lock +815 -0
- data/README.md +269 -76
- data/bin/cfndk +3 -18
- data/cfndk.gemspec +15 -6
- data/docker/Dockerfile +8 -0
- data/docker/build.sh +3 -0
- data/docker/cfndk.sh +14 -0
- data/lib/cfndk.rb +36 -0
- data/lib/cfndk/change_set_command.rb +103 -0
- data/lib/cfndk/command.rb +125 -119
- data/lib/cfndk/config_file_loadable.rb +13 -0
- data/lib/cfndk/credential_provider_chain.rb +12 -42
- data/lib/cfndk/credential_resolvable.rb +10 -0
- data/lib/cfndk/diff.rb +38 -0
- data/lib/cfndk/global_config.rb +46 -0
- data/lib/cfndk/key_pair.rb +66 -14
- data/lib/cfndk/key_pair_command.rb +60 -0
- data/lib/cfndk/key_pairs.rb +22 -5
- data/lib/cfndk/logger.rb +12 -3
- data/lib/cfndk/stack.rb +427 -126
- data/lib/cfndk/stack_command.rb +128 -0
- data/lib/cfndk/stacks.rb +48 -22
- data/lib/cfndk/subcommand_help_returnable.rb +16 -0
- data/lib/cfndk/template_packager.rb +210 -0
- data/lib/cfndk/uuid.rb +10 -0
- data/lib/cfndk/version.rb +1 -1
- data/skel/cfndk.yml +4 -0
- data/spec/.gitignore +1 -0
- data/spec/cfndk_change_set_create_spec.rb +436 -0
- data/spec/cfndk_change_set_destroy_spec.rb +160 -0
- data/spec/cfndk_change_set_execute_spec.rb +179 -0
- data/spec/cfndk_change_set_report_spec.rb +107 -0
- data/spec/cfndk_change_set_spec.rb +37 -0
- data/spec/cfndk_create_spec.rb +504 -0
- data/spec/cfndk_destroy_spec.rb +148 -0
- data/spec/cfndk_keypiar_spec.rb +397 -0
- data/spec/cfndk_report_spec.rb +164 -0
- data/spec/cfndk_spec.rb +103 -0
- data/spec/cfndk_stack_create_spec.rb +814 -0
- data/spec/cfndk_stack_destroy_spec.rb +225 -0
- data/spec/cfndk_stack_report_spec.rb +181 -0
- data/spec/cfndk_stack_spec.rb +133 -0
- data/spec/cfndk_stack_update_spec.rb +553 -0
- data/spec/fixtures/big_vpc.yaml +533 -0
- data/spec/fixtures/empty_resource.yaml +2 -0
- data/spec/fixtures/iam.json +8 -0
- data/spec/fixtures/iam.yaml +38 -0
- data/spec/fixtures/iam_different.json +8 -0
- data/spec/fixtures/invalid_vpc.yaml +21 -0
- data/spec/fixtures/lambda_function/index.js +4 -0
- data/spec/fixtures/lambda_function/lambda_function.json +4 -0
- data/spec/fixtures/lambda_function/lambda_function.yaml +28 -0
- data/spec/fixtures/nested_stack.json +35 -0
- data/spec/fixtures/nested_stack.yaml +20 -0
- data/spec/fixtures/serverless_function/index.js +4 -0
- data/spec/fixtures/serverless_function/serverless_function.json +4 -0
- data/spec/fixtures/serverless_function/serverless_function.yaml +21 -0
- data/spec/fixtures/sg.json +8 -0
- data/spec/fixtures/sg.yaml +27 -0
- data/spec/fixtures/sg_different.yaml +22 -0
- data/spec/fixtures/stack.json +8 -0
- data/spec/fixtures/stack.template.json +39 -0
- data/spec/fixtures/stack.yaml +22 -0
- data/spec/fixtures/vpc.json +8 -0
- data/spec/fixtures/vpc.template.json +40 -0
- data/spec/fixtures/vpc.yaml +21 -0
- data/spec/fixtures/vpc_different.yaml +21 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/aruba.rb +6 -0
- data/vagrant/Vagrantfile +89 -0
- metadata +259 -31
data/bin/cfndk
CHANGED
@@ -1,22 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'bundler/setup'
|
4
|
-
|
5
|
-
require 'rainbow/ext/string'
|
6
|
-
require 'optparse'
|
7
|
-
require 'fileutils'
|
8
|
-
require 'pathname'
|
9
|
-
require 'erb'
|
10
|
-
require 'yaml'
|
11
|
-
require 'json'
|
12
|
-
require 'aws-sdk'
|
13
|
-
require 'terminal-table'
|
14
|
-
require 'securerandom'
|
15
|
-
require 'logger'
|
16
|
-
|
17
|
-
require 'cfndk.rb'
|
18
|
-
|
19
3
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
20
4
|
|
21
|
-
|
22
|
-
|
5
|
+
require 'cfndk'
|
6
|
+
|
7
|
+
exit CFnDK::Command.start(ARGV)
|
data/cfndk.gemspec
CHANGED
@@ -18,11 +18,20 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency '
|
22
|
-
spec.add_development_dependency '
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rspec'
|
23
|
+
spec.add_development_dependency 'aruba'
|
24
|
+
spec.add_development_dependency 'simplecov'
|
25
|
+
spec.add_development_dependency 'awspec'
|
26
|
+
spec.add_development_dependency 'parallel_tests'
|
23
27
|
|
24
|
-
spec.add_dependency '
|
25
|
-
spec.add_dependency '
|
26
|
-
spec.add_dependency '
|
27
|
-
spec.add_dependency '
|
28
|
+
spec.add_dependency 'bundler'
|
29
|
+
spec.add_dependency 'thor'
|
30
|
+
spec.add_dependency 'rainbow'
|
31
|
+
spec.add_dependency 'rubyzip', '1.3.0'
|
32
|
+
spec.add_dependency 'aws-sdk'
|
33
|
+
spec.add_dependency 'camelizable'
|
34
|
+
spec.add_dependency 'terminal-table'
|
35
|
+
spec.add_dependency 'diff-lcs'
|
36
|
+
spec.add_dependency 'polyfill'
|
28
37
|
end
|
data/docker/Dockerfile
ADDED
data/docker/build.sh
ADDED
data/docker/cfndk.sh
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
WORK_DIR=`pwd`
|
4
|
+
|
5
|
+
docker run \
|
6
|
+
-v $WORK_DIR:/home/cfndk \
|
7
|
+
-v $HOME/.aws:/root/.aws \
|
8
|
+
-e AWS_PROFILE=$AWS_PROFILE \
|
9
|
+
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
|
10
|
+
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
|
11
|
+
-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
|
12
|
+
-w /home/cfndk \
|
13
|
+
-it amakata/cfndk:latest \
|
14
|
+
"$@"
|
data/lib/cfndk.rb
CHANGED
@@ -1,12 +1,48 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
|
3
|
+
require 'rainbow/ext/string'
|
4
|
+
require 'camelizable'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'pathname'
|
7
|
+
require 'ostruct'
|
8
|
+
require 'erb'
|
9
|
+
require 'yaml'
|
10
|
+
require 'json'
|
11
|
+
require 'zip'
|
12
|
+
require 'aws-sdk'
|
13
|
+
require 'terminal-table'
|
14
|
+
require 'securerandom'
|
15
|
+
require 'logger'
|
16
|
+
require 'thor'
|
17
|
+
require 'diff/lcs'
|
18
|
+
require 'diff/lcs/hunk'
|
19
|
+
require 'polyfill'
|
20
|
+
|
21
|
+
if ENV['CFNDK_COVERAGE']
|
22
|
+
require 'simplecov'
|
23
|
+
root = File.expand_path('../../', __FILE__)
|
24
|
+
SimpleCov.root(root)
|
25
|
+
end
|
26
|
+
|
1
27
|
require 'cfndk/version'
|
2
28
|
require 'cfndk/stack'
|
3
29
|
require 'cfndk/stacks'
|
4
30
|
require 'cfndk/key_pair'
|
5
31
|
require 'cfndk/key_pairs'
|
6
32
|
require 'cfndk/erb_string'
|
33
|
+
require 'cfndk/global_config'
|
7
34
|
require 'cfndk/logger'
|
8
35
|
require 'cfndk/credential_provider_chain'
|
36
|
+
require 'cfndk/subcommand_help_returnable'
|
37
|
+
require 'cfndk/credential_resolvable'
|
38
|
+
require 'cfndk/config_file_loadable'
|
39
|
+
require 'cfndk/key_pair_command'
|
40
|
+
require 'cfndk/stack_command'
|
41
|
+
require 'cfndk/change_set_command'
|
9
42
|
require 'cfndk/command'
|
43
|
+
require 'cfndk/template_packager'
|
44
|
+
require 'cfndk/diff'
|
45
|
+
require 'cfndk/uuid'
|
10
46
|
|
11
47
|
module CFnDK
|
12
48
|
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module CFnDK
|
2
|
+
class ChangeSetCommand < Thor
|
3
|
+
include SubcommandHelpReturnable
|
4
|
+
include ConfigFileLoadable
|
5
|
+
include CredentialResolvable
|
6
|
+
|
7
|
+
class_option :verbose, type: :boolean, aliases: 'v', desc: 'More verbose output.'
|
8
|
+
class_option :color, type: :boolean, default: true, desc: 'Use colored output'
|
9
|
+
class_option :config_path, type: :string, aliases: 'c', default: "#{Dir.getwd}/cfndk.yml", desc: 'The configuration file to use'
|
10
|
+
class_option :stack_names, type: :array, aliases: 's', desc: 'Target stack names'
|
11
|
+
|
12
|
+
desc 'create', 'Create change set'
|
13
|
+
option :uuid, type: :string, aliases: 'u', default: ENV['CFNDK_UUID'] || nil, desc: 'Use UUID'
|
14
|
+
option :change_set_uuid, type: :string, default: ENV['CFNDK_CHANGE_SET_UUID'] || nil, desc: 'Use Change Set UUID'
|
15
|
+
option :properties, type: :hash, aliases: 'p', default: {}, desc: 'Set property'
|
16
|
+
def create
|
17
|
+
CFnDK.logger.info 'create...'.color(:green)
|
18
|
+
data = load_config_data(options)
|
19
|
+
credentials = resolve_credential(data, options)
|
20
|
+
global_config = CFnDK::GlobalConfig.new(data, options)
|
21
|
+
stacks = CFnDK::Stacks.new(data, options, credentials)
|
22
|
+
|
23
|
+
global_config.pre_command_execute
|
24
|
+
stacks.pre_command_execute
|
25
|
+
stacks.validate
|
26
|
+
stacks.create_change_set
|
27
|
+
stacks.post_command_execute
|
28
|
+
global_config.post_command_execute
|
29
|
+
return 0
|
30
|
+
rescue => e
|
31
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
32
|
+
e.backtrace_locations.each do |line|
|
33
|
+
CFnDK.logger.debug line
|
34
|
+
end
|
35
|
+
return 1
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'execute', 'Execute change set'
|
39
|
+
option :uuid, type: :string, aliases: 'u', default: ENV['CFNDK_UUID'] || nil, desc: 'Use UUID'
|
40
|
+
option :change_set_uuid, type: :string, default: ENV['CFNDK_CHANGE_SET_UUID'] || nil, desc: 'Use Change Set UUID'
|
41
|
+
def execute
|
42
|
+
CFnDK.logger.info 'execute...'.color(:green)
|
43
|
+
data = load_config_data(options)
|
44
|
+
credentials = resolve_credential(data, options)
|
45
|
+
stacks = CFnDK::Stacks.new(data, options, credentials)
|
46
|
+
|
47
|
+
stacks.execute_change_set
|
48
|
+
return 0
|
49
|
+
rescue => e
|
50
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
51
|
+
e.backtrace_locations.each do |line|
|
52
|
+
CFnDK.logger.debug line
|
53
|
+
end
|
54
|
+
return 1
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'destroy', 'Destroy change set'
|
58
|
+
option :force, type: :boolean, aliases: 'f', default: false, desc: 'Say yes to all prompts for confirmation'
|
59
|
+
option :uuid, type: :string, aliases: 'u', default: ENV['CFNDK_UUID'] || nil, desc: 'Use UUID'
|
60
|
+
option :change_set_uuid, type: :string, default: ENV['CFNDK_CHANGE_SET_UUID'] || nil, desc: 'Use Change Set UUID'
|
61
|
+
def destroy
|
62
|
+
CFnDK.logger.info 'destroy...'.color(:green)
|
63
|
+
data = load_config_data(options)
|
64
|
+
credentials = resolve_credential(data, options)
|
65
|
+
|
66
|
+
stacks = CFnDK::Stacks.new(data, options, credentials)
|
67
|
+
|
68
|
+
if options[:force] || yes?('Are you sure you want to destroy? (y/n)', :yellow)
|
69
|
+
stacks.delete_change_set
|
70
|
+
return 0
|
71
|
+
else
|
72
|
+
CFnDK.logger.info 'destroy command was canceled'.color(:green)
|
73
|
+
return 2
|
74
|
+
end
|
75
|
+
rescue => e
|
76
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
77
|
+
e.backtrace_locations.each do |line|
|
78
|
+
CFnDK.logger.debug line
|
79
|
+
end
|
80
|
+
return 1
|
81
|
+
end
|
82
|
+
|
83
|
+
desc 'report', 'Report change set'
|
84
|
+
option :uuid, type: :string, aliases: 'u', default: ENV['CFNDK_UUID'] || nil, desc: 'Use UUID'
|
85
|
+
option :change_set_uuid, type: :string, default: ENV['CFNDK_CHANGE_SET_UUID'] || nil, desc: 'Use Change Set UUID'
|
86
|
+
option :types, type: :array, default: %w(tag parameter changes), desc: 'Report type'
|
87
|
+
def report
|
88
|
+
CFnDK.logger.info 'report...'.color(:green)
|
89
|
+
data = load_config_data(options)
|
90
|
+
credentials = resolve_credential(data, options)
|
91
|
+
|
92
|
+
stacks = CFnDK::Stacks.new(data, options, credentials)
|
93
|
+
stacks.report_change_set
|
94
|
+
return 0
|
95
|
+
rescue => e
|
96
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
97
|
+
e.backtrace_locations.each do |line|
|
98
|
+
CFnDK.logger.debug line
|
99
|
+
end
|
100
|
+
return 1
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/cfndk/command.rb
CHANGED
@@ -1,136 +1,142 @@
|
|
1
1
|
module CFnDK
|
2
|
-
class Command
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
force: false,
|
11
|
-
}
|
12
|
-
|
13
|
-
@opt = OptionParser.new do |o|
|
14
|
-
o.version = CFnDK::VERSION
|
15
|
-
o.summary_indent = ' ' * 4
|
16
|
-
o.banner = "Version: #{CFnDK::VERSION} \nUsage: cfndk [cmd] [options]"
|
17
|
-
o.on_head('[cmd]',
|
18
|
-
' init create config YAML file',
|
19
|
-
' create create stacks',
|
20
|
-
' update update stacks',
|
21
|
-
' create-or-changeset create stacks or create changeset',
|
22
|
-
' destroy destroy stacks',
|
23
|
-
' generate-uuid generate UUID',
|
24
|
-
' report-event report stack event',
|
25
|
-
' report-stack report stack',
|
26
|
-
' report-stack-resource report stack resource',
|
27
|
-
'[enviroment variables]',
|
28
|
-
" AWS_PROFILE: #{ENV['AWS_PROFILE']}",
|
29
|
-
" AWS_DEFAULT_REGION: #{ENV['AWS_DEFAULT_REGION']}",
|
30
|
-
" AWS_REGION: #{ENV['AWS_REGION']}",
|
31
|
-
" AWS_ACCESS_KEY_ID: #{ENV['AWS_ACCESS_KEY_ID']}",
|
32
|
-
" AWS_SECRET_ACCESS_KEY: #{ENV['AWS_SECRET_ACCESS_KEY']}",
|
33
|
-
" AWS_SESSION_TOKEN: #{ENV['AWS_SECRET_ACCESS_KEY']}",
|
34
|
-
" AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: #{ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI']}",
|
35
|
-
'[options]')
|
36
|
-
o.on('-v', '--verbose', 'verbose mode') { |v| @option[:v] = v }
|
37
|
-
o.on('-c', '--config_path cfndi.yml', "config path (default: #{@option[:config_path]})") { |v| @option[:config_path] = v }
|
38
|
-
o.on('-p', '--properties name=value', 'properties') do |v|
|
39
|
-
md = v.match(/^([a-zA-Z_]+[a-zA-Z0-9_]*)=(.*)$/)
|
40
|
-
if md
|
41
|
-
@option[:properties][md[0]] = md[1]
|
42
|
-
else
|
43
|
-
raise "invalid properties: '#{v}'" unless md
|
44
|
-
end
|
45
|
-
end
|
46
|
-
o.on('-a', '--auto-uuid') { @option[:uuid] = SecureRandom.uuid }
|
47
|
-
o.on('-u', '--uuid uuid') { |v| @option[:uuid] = v }
|
48
|
-
o.on('-n', '--stack-names name1,name2') { |v| @option[:stack_names] = v.split(/\s*,\s*/) }
|
49
|
-
o.on('--no-color') { |b| Rainbow.enabled = false }
|
50
|
-
o.on('-f', '--force') { |b| @option[:force] = true }
|
51
|
-
o.permute!(ARGV)
|
2
|
+
class Command < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
include ConfigFileLoadable
|
5
|
+
include CredentialResolvable
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def exit_on_failure?
|
9
|
+
true
|
52
10
|
end
|
53
|
-
@logger = CFnDK::Logger.new(@option)
|
54
11
|
end
|
55
12
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
elsif ARGV[0] == 'generate-uuid'
|
61
|
-
puts SecureRandom.uuid
|
62
|
-
return 0
|
63
|
-
elsif ARGV[0] == 'init'
|
64
|
-
if File.file?(@option[:config_path])
|
65
|
-
@logger.error "File exist. #{@option[:config_path]}".color(:red)
|
66
|
-
return 1
|
67
|
-
end
|
68
|
-
@logger.info 'init...'.color(:green)
|
69
|
-
FileUtils.cp_r(Dir.glob(File.dirname(__FILE__) + '/../../skel/*'), './')
|
70
|
-
@logger.info "create #{@option[:config_path]}".color(:green)
|
71
|
-
return 0
|
72
|
-
end
|
13
|
+
def help(command = nil, subcommand = false)
|
14
|
+
super(command, subcommand)
|
15
|
+
2
|
16
|
+
end
|
73
17
|
|
74
|
-
|
75
|
-
|
18
|
+
class_option :verbose, type: :boolean, aliases: 'v', desc: 'More verbose output.'
|
19
|
+
class_option :color, type: :boolean, default: true, desc: 'Use colored output'
|
20
|
+
|
21
|
+
desc 'generate-uuid', 'Print UUID'
|
22
|
+
def generate_uuid
|
23
|
+
puts SecureRandom.uuid
|
24
|
+
0
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'version', 'Print version'
|
28
|
+
def version
|
29
|
+
puts CFnDK::VERSION
|
30
|
+
0
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'init', 'Craete sample cfndk.yml & CloudFormation yaml & json files.'
|
34
|
+
def init
|
35
|
+
config_path = "#{Dir.getwd}/cfndk.yml"
|
36
|
+
if File.file?(config_path)
|
37
|
+
CFnDK.logger.error "File exist. #{config_path}".color(:red)
|
76
38
|
return 1
|
77
39
|
end
|
40
|
+
CFnDK.logger.info 'init...'.color(:green)
|
41
|
+
FileUtils.cp_r(Dir.glob(File.dirname(__FILE__) + '/../../skel/*'), './')
|
42
|
+
CFnDK.logger.info "create #{config_path}".color(:green)
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'create', 'Create keypair & stack'
|
46
|
+
option :config_path, type: :string, aliases: 'c', default: "#{Dir.getwd}/cfndk.yml", desc: 'The configuration file to use'
|
47
|
+
option :uuid, type: :string, aliases: 'u', default: ENV['CFNDK_UUID'] || nil, desc: 'Use UUID'
|
48
|
+
option :properties, type: :hash, aliases: 'p', default: {}, desc: 'Set property'
|
49
|
+
option :stack_names, type: :array, aliases: 's', desc: 'Target stack names'
|
50
|
+
option :keypair_names, type: :array, desc: 'Target keypair names'
|
51
|
+
def create
|
52
|
+
CFnDK.logger.info 'create...'.color(:green)
|
53
|
+
data = load_config_data(options)
|
54
|
+
credentials = resolve_credential(data, options)
|
55
|
+
global_config = CFnDK::GlobalConfig.new(data, options)
|
56
|
+
stacks = CFnDK::Stacks.new(data, options, credentials)
|
57
|
+
keypairs = CFnDK::KeyPairs.new(data, options, credentials)
|
78
58
|
|
79
|
-
|
80
|
-
|
81
|
-
stacks
|
82
|
-
keypairs
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
@logger.info 'report stack resource...'.color(:green)
|
114
|
-
stacks.report_stack_resource
|
59
|
+
global_config.pre_command_execute
|
60
|
+
stacks.pre_command_execute
|
61
|
+
stacks.validate
|
62
|
+
keypairs.pre_command_execute
|
63
|
+
keypairs.create
|
64
|
+
keypairs.post_command_execute
|
65
|
+
stacks.create
|
66
|
+
stacks.post_command_execute
|
67
|
+
global_config.post_command_execute
|
68
|
+
return 0
|
69
|
+
rescue => e
|
70
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
71
|
+
e.backtrace_locations.each do |line|
|
72
|
+
CFnDK.logger.debug line
|
73
|
+
end
|
74
|
+
return 1
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'destroy', 'Destroy keypair & stack'
|
78
|
+
option :config_path, type: :string, aliases: 'c', default: "#{Dir.getwd}/cfndk.yml", desc: 'The configuration file to use'
|
79
|
+
option :force, type: :boolean, aliases: 'f', default: false, desc: 'Say yes to all prompts for confirmation'
|
80
|
+
option :uuid, type: :string, aliases: 'u', default: ENV['CFNDK_UUID'] || nil, desc: 'Use UUID'
|
81
|
+
def destroy
|
82
|
+
CFnDK.logger.info 'destroy...'.color(:green)
|
83
|
+
data = load_config_data(options)
|
84
|
+
credentials = resolve_credential(data, options)
|
85
|
+
|
86
|
+
stacks = CFnDK::Stacks.new(data, options, credentials)
|
87
|
+
keypairs = CFnDK::KeyPairs.new(data, options, credentials)
|
88
|
+
|
89
|
+
if options[:force] || yes?('Are you sure you want to destroy? (y/n)', :yellow)
|
90
|
+
stacks.destroy
|
91
|
+
keypairs.destroy
|
92
|
+
return 0
|
115
93
|
else
|
116
|
-
|
94
|
+
CFnDK.logger.info 'destroy command was canceled'.color(:green)
|
117
95
|
return 2
|
118
96
|
end
|
119
|
-
|
97
|
+
rescue => e
|
98
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
99
|
+
e.backtrace_locations.each do |line|
|
100
|
+
CFnDK.logger.debug line
|
101
|
+
end
|
102
|
+
return 1
|
120
103
|
end
|
121
104
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
105
|
+
desc 'report', 'Report stack'
|
106
|
+
option :config_path, type: :string, aliases: 'c', default: "#{Dir.getwd}/cfndk.yml", desc: 'The configuration file to use'
|
107
|
+
option :uuid, type: :string, aliases: 'u', default: ENV['CFNDK_UUID'] || nil, desc: 'Use UUID'
|
108
|
+
option :stack_names, type: :array, aliases: 's', desc: 'Target stack names'
|
109
|
+
option :types, type: :array, default: %w(tag output parameter resource event), desc: 'Report type'
|
110
|
+
def report
|
111
|
+
CFnDK.logger.info 'report...'.color(:green)
|
112
|
+
|
113
|
+
data = load_config_data(options)
|
114
|
+
credentials = resolve_credential(data, options)
|
115
|
+
|
116
|
+
stacks = CFnDK::Stacks.new(data, options, credentials)
|
117
|
+
stacks.report
|
118
|
+
return 0
|
119
|
+
rescue => e
|
120
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
121
|
+
e.backtrace_locations.each do |line|
|
122
|
+
CFnDK.logger.debug line
|
133
123
|
end
|
124
|
+
return 1
|
134
125
|
end
|
126
|
+
|
127
|
+
no_commands do
|
128
|
+
def invoke_command(command, *args)
|
129
|
+
CFnDK.logger = CFnDKLogger.new(options)
|
130
|
+
Rainbow.enabled = false unless options[:color]
|
131
|
+
super
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
desc 'keypair SUBCOMMAND ...ARGS', 'Manage keypair'
|
136
|
+
subcommand 'keypair', KeyPairCommand
|
137
|
+
desc 'stack SUBCOMMAND ...ARGS', 'Manage stack'
|
138
|
+
subcommand 'stack', StackCommand
|
139
|
+
desc 'changeset SUBCOMMAND ...ARGS', 'Manage change set'
|
140
|
+
subcommand 'changeset', ChangeSetCommand
|
135
141
|
end
|
136
142
|
end
|