knife-cfn 0.1.9 → 0.1.10
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/chef/knife/cfn_create.rb +125 -125
- data/lib/chef/knife/cfn_outputs.rb +108 -108
- data/lib/chef/knife/cfn_resources.rb +86 -0
- data/lib/knife-cfn/version.rb +3 -0
- metadata +4 -3
- data/lib/knife-cnf/version.rb +0 -3
@@ -1,125 +1,125 @@
|
|
1
|
-
#
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
-
# you may not use this file except in compliance with the License.
|
4
|
-
# You may obtain a copy of the License at
|
5
|
-
#
|
6
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
-
#
|
8
|
-
# Unless required by applicable law or agreed to in writing, software
|
9
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
-
# See the License for the specific language governing permissions and
|
12
|
-
# limitations under the License.
|
13
|
-
#
|
14
|
-
|
15
|
-
require 'chef/knife'
|
16
|
-
require 'chef/knife/cfn_base'
|
17
|
-
|
18
|
-
class Chef
|
19
|
-
class Knife
|
20
|
-
class CfnCreate < Chef::Knife::CfnBase
|
21
|
-
|
22
|
-
deps do
|
23
|
-
require 'fog'
|
24
|
-
require 'readline'
|
25
|
-
require 'chef/json_compat'
|
26
|
-
require 'chef/knife/bootstrap'
|
27
|
-
Chef::Knife::Bootstrap.load_deps
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife cfn create <stack name> (options)"
|
31
|
-
|
32
|
-
option :capabilities,
|
33
|
-
:short => "-
|
34
|
-
:long => "--capabilities CAPABILITY1,CAPABILITY2,CAPABILITY3..",
|
35
|
-
:description => "The explicitly approved capabilities that may be used during this stack creation",
|
36
|
-
:proc => Proc.new { |capabilities| capabilities.split(',') }
|
37
|
-
|
38
|
-
option :disable_rollback,
|
39
|
-
:short => "-d",
|
40
|
-
:long => "--disable-rollback",
|
41
|
-
:description => "Flag to disable rollback of created resources when failures are encountered during stack creation. The default value is 'false'",
|
42
|
-
:proc => Proc.new { |d| Chef::Config[:knife][:disable_rollback] = "true" }
|
43
|
-
|
44
|
-
option :template_file,
|
45
|
-
:short => "-f TEMPLATE_FILE",
|
46
|
-
:long => "--template-file TEMPLATE_FILE",
|
47
|
-
:description => "Path to the file that contains the template",
|
48
|
-
:proc => Proc.new { |f| Chef::Config[:knife][:template_file] = f }
|
49
|
-
|
50
|
-
option :notification_arns,
|
51
|
-
:short => "-n NOTIFICATION_ARN1,NOTIFICATION_ARN2,NOTIFICATION_ARN3..",
|
52
|
-
:long => "--notification-arns VALUE1,VALUE2,VALUE3..",
|
53
|
-
:description => "SNS ARNs to receive notification about the stack",
|
54
|
-
:proc => Proc.new { |notification_arns| notification_arns.split(',') }
|
55
|
-
|
56
|
-
option :parameters,
|
57
|
-
:short => "-p 'key1=value1;key2=value2...'",
|
58
|
-
:long => "--parameters 'key1=value1;key2=value2...'",
|
59
|
-
:description => "Parameter values used to create the stack",
|
60
|
-
:proc => Proc.new { |parameters| parameters.split(';') }
|
61
|
-
|
62
|
-
option :timeout,
|
63
|
-
:short => "-t TIMEOUT_VALUE",
|
64
|
-
:long => "--timeout TIMEOUT_VALUE",
|
65
|
-
:description => " Stack creation timeout in minutes",
|
66
|
-
:proc => Proc.new { |t| Chef::Config[:knife][:timeout] = t }
|
67
|
-
|
68
|
-
option :template_url,
|
69
|
-
:short => "-u TEMPLATE_URL",
|
70
|
-
:long => "--template-file TEMPLATE_URL",
|
71
|
-
:description => "Path of the URL that contains the template. This must be a reference to a template in an S3 bucket in the same region that the stack will be created in",
|
72
|
-
:proc => Proc.new { |u| Chef::Config[:knife][:template_url] = u }
|
73
|
-
|
74
|
-
def run
|
75
|
-
$stdout.sync = true
|
76
|
-
|
77
|
-
validate!
|
78
|
-
|
79
|
-
stack_name = @name_args[0]
|
80
|
-
|
81
|
-
if stack_name.nil?
|
82
|
-
show_usage
|
83
|
-
ui.error("You must specify a stack name")
|
84
|
-
exit 1
|
85
|
-
end
|
86
|
-
|
87
|
-
begin
|
88
|
-
response = connection.create_stack(stack_name, create_create_def)
|
89
|
-
rescue Excon::Errors::BadRequest => e
|
90
|
-
i= e.response.body.index("<Message>")
|
91
|
-
j = e.response.body.index("</Message>")
|
92
|
-
if !i.nil? and !j.nil?
|
93
|
-
ui.error(e.response.body[i+9,j-i-9])
|
94
|
-
else
|
95
|
-
print "\n#{e.response.body}"
|
96
|
-
end
|
97
|
-
exit 1
|
98
|
-
else
|
99
|
-
message = "Stack #{stack_name} creation started"
|
100
|
-
print "\n#{ui.color(message, :green)}\n"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def create_create_def
|
106
|
-
create_def = {}
|
107
|
-
template_file = locate_config_value(:template_file)
|
108
|
-
if template_file != nil and template_file != ""
|
109
|
-
doc = File.open(template_file, 'rb') { |file| file.read }
|
110
|
-
create_def['TemplateBody'] = doc
|
111
|
-
end
|
112
|
-
create_def['TemplateURL'] = locate_config_value(:template_url)
|
113
|
-
create_def['Capabilities'] = locate_config_value(:capabilities)
|
114
|
-
create_def['DisableRollback'] = locate_config_value(:disable_rollback)
|
115
|
-
create_def['NotificationARNs'] = locate_config_value(:notification_arns)
|
116
|
-
hashed_parameters={}
|
117
|
-
parameters = locate_config_value(:parameters)
|
118
|
-
parameters.map{ |t| key,val=t.split('='); hashed_parameters[key]=val} unless parameters.nil?
|
119
|
-
create_def['Parameters'] = hashed_parameters
|
120
|
-
create_def['TimeoutInMinutes'] = locate_config_value(:timeout)
|
121
|
-
create_def
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
end
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
require 'chef/knife'
|
16
|
+
require 'chef/knife/cfn_base'
|
17
|
+
|
18
|
+
class Chef
|
19
|
+
class Knife
|
20
|
+
class CfnCreate < Chef::Knife::CfnBase
|
21
|
+
|
22
|
+
deps do
|
23
|
+
require 'fog'
|
24
|
+
require 'readline'
|
25
|
+
require 'chef/json_compat'
|
26
|
+
require 'chef/knife/bootstrap'
|
27
|
+
Chef::Knife::Bootstrap.load_deps
|
28
|
+
end
|
29
|
+
|
30
|
+
banner "knife cfn create <stack name> (options)"
|
31
|
+
|
32
|
+
option :capabilities,
|
33
|
+
:short => "-C CAPABILITY..",
|
34
|
+
:long => "--capabilities CAPABILITY1,CAPABILITY2,CAPABILITY3..",
|
35
|
+
:description => "The explicitly approved capabilities that may be used during this stack creation",
|
36
|
+
:proc => Proc.new { |capabilities| capabilities.split(',') }
|
37
|
+
|
38
|
+
option :disable_rollback,
|
39
|
+
:short => "-d",
|
40
|
+
:long => "--disable-rollback",
|
41
|
+
:description => "Flag to disable rollback of created resources when failures are encountered during stack creation. The default value is 'false'",
|
42
|
+
:proc => Proc.new { |d| Chef::Config[:knife][:disable_rollback] = "true" }
|
43
|
+
|
44
|
+
option :template_file,
|
45
|
+
:short => "-f TEMPLATE_FILE",
|
46
|
+
:long => "--template-file TEMPLATE_FILE",
|
47
|
+
:description => "Path to the file that contains the template",
|
48
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:template_file] = f }
|
49
|
+
|
50
|
+
option :notification_arns,
|
51
|
+
:short => "-n NOTIFICATION_ARN1,NOTIFICATION_ARN2,NOTIFICATION_ARN3..",
|
52
|
+
:long => "--notification-arns VALUE1,VALUE2,VALUE3..",
|
53
|
+
:description => "SNS ARNs to receive notification about the stack",
|
54
|
+
:proc => Proc.new { |notification_arns| notification_arns.split(',') }
|
55
|
+
|
56
|
+
option :parameters,
|
57
|
+
:short => "-p 'key1=value1;key2=value2...'",
|
58
|
+
:long => "--parameters 'key1=value1;key2=value2...'",
|
59
|
+
:description => "Parameter values used to create the stack",
|
60
|
+
:proc => Proc.new { |parameters| parameters.split(';') }
|
61
|
+
|
62
|
+
option :timeout,
|
63
|
+
:short => "-t TIMEOUT_VALUE",
|
64
|
+
:long => "--timeout TIMEOUT_VALUE",
|
65
|
+
:description => " Stack creation timeout in minutes",
|
66
|
+
:proc => Proc.new { |t| Chef::Config[:knife][:timeout] = t }
|
67
|
+
|
68
|
+
option :template_url,
|
69
|
+
:short => "-u TEMPLATE_URL",
|
70
|
+
:long => "--template-file TEMPLATE_URL",
|
71
|
+
:description => "Path of the URL that contains the template. This must be a reference to a template in an S3 bucket in the same region that the stack will be created in",
|
72
|
+
:proc => Proc.new { |u| Chef::Config[:knife][:template_url] = u }
|
73
|
+
|
74
|
+
def run
|
75
|
+
$stdout.sync = true
|
76
|
+
|
77
|
+
validate!
|
78
|
+
|
79
|
+
stack_name = @name_args[0]
|
80
|
+
|
81
|
+
if stack_name.nil?
|
82
|
+
show_usage
|
83
|
+
ui.error("You must specify a stack name")
|
84
|
+
exit 1
|
85
|
+
end
|
86
|
+
|
87
|
+
begin
|
88
|
+
response = connection.create_stack(stack_name, create_create_def)
|
89
|
+
rescue Excon::Errors::BadRequest => e
|
90
|
+
i= e.response.body.index("<Message>")
|
91
|
+
j = e.response.body.index("</Message>")
|
92
|
+
if !i.nil? and !j.nil?
|
93
|
+
ui.error(e.response.body[i+9,j-i-9])
|
94
|
+
else
|
95
|
+
print "\n#{e.response.body}"
|
96
|
+
end
|
97
|
+
exit 1
|
98
|
+
else
|
99
|
+
message = "Stack #{stack_name} creation started"
|
100
|
+
print "\n#{ui.color(message, :green)}\n"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def create_create_def
|
106
|
+
create_def = {}
|
107
|
+
template_file = locate_config_value(:template_file)
|
108
|
+
if template_file != nil and template_file != ""
|
109
|
+
doc = File.open(template_file, 'rb') { |file| file.read }
|
110
|
+
create_def['TemplateBody'] = doc
|
111
|
+
end
|
112
|
+
create_def['TemplateURL'] = locate_config_value(:template_url)
|
113
|
+
create_def['Capabilities'] = locate_config_value(:capabilities)
|
114
|
+
create_def['DisableRollback'] = locate_config_value(:disable_rollback)
|
115
|
+
create_def['NotificationARNs'] = locate_config_value(:notification_arns)
|
116
|
+
hashed_parameters={}
|
117
|
+
parameters = locate_config_value(:parameters)
|
118
|
+
parameters.map{ |t| key,val=t.split('='); hashed_parameters[key]=val} unless parameters.nil?
|
119
|
+
create_def['Parameters'] = hashed_parameters
|
120
|
+
create_def['TimeoutInMinutes'] = locate_config_value(:timeout)
|
121
|
+
create_def
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
@@ -1,108 +1,108 @@
|
|
1
|
-
#
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
-
# you may not use this file except in compliance with the License.
|
4
|
-
# You may obtain a copy of the License at
|
5
|
-
#
|
6
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
-
#
|
8
|
-
# Unless required by applicable law or agreed to in writing, software
|
9
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
-
# See the License for the specific language governing permissions and
|
12
|
-
# limitations under the License.
|
13
|
-
#
|
14
|
-
|
15
|
-
require 'chef/knife'
|
16
|
-
require 'chef/knife/cfn_base'
|
17
|
-
|
18
|
-
class Chef
|
19
|
-
class Knife
|
20
|
-
class CfnOutputs < Chef::Knife::CfnBase
|
21
|
-
|
22
|
-
deps do
|
23
|
-
require 'fog'
|
24
|
-
require 'readline'
|
25
|
-
require 'chef/json_compat'
|
26
|
-
require 'chef/knife/bootstrap'
|
27
|
-
Chef::Knife::Bootstrap.load_deps
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife cfn outputs <stack name>"
|
31
|
-
|
32
|
-
option :output_parameter_format,
|
33
|
-
:short => "-o",
|
34
|
-
:long => "--output_parameter_format",
|
35
|
-
:description => "Stack output is formatted in a suitable syntax to use for parameters for another stack",
|
36
|
-
:proc => Proc.new{ |o| Chef::Config[:knife][:output_format] = "parameter" }
|
37
|
-
|
38
|
-
def run
|
39
|
-
$stdout.sync = true
|
40
|
-
|
41
|
-
validate!
|
42
|
-
|
43
|
-
stack_name = @name_args[0]
|
44
|
-
if stack_name.nil?
|
45
|
-
show_usage
|
46
|
-
ui.error("You must specify a stack name")
|
47
|
-
exit 1
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
ui.color("Stack", :bold),
|
52
|
-
ui.color('Output Key', :bold),
|
53
|
-
ui.color('Output Value', :bold),
|
54
|
-
ui.color('Description', :bold)
|
55
|
-
]
|
56
|
-
|
57
|
-
@name_args.each do |stack_name|
|
58
|
-
options = {}
|
59
|
-
options["StackName"] = stack_name
|
60
|
-
data = Array.new
|
61
|
-
begin
|
62
|
-
response = connection.describe_stacks(options)
|
63
|
-
data = response.body["Stacks"]
|
64
|
-
|
65
|
-
rescue Excon::Errors::BadRequest => e
|
66
|
-
i= e.response.body.index("<Message>")
|
67
|
-
j = e.response.body.index("</Message>")
|
68
|
-
if !i.nil? and !j.nil?
|
69
|
-
ui.error(e.response.body[i+9,j-i-9])
|
70
|
-
else
|
71
|
-
print "\n#{e.response.body}"
|
72
|
-
end
|
73
|
-
exit 1
|
74
|
-
else
|
75
|
-
parameter_output=""
|
76
|
-
delim=""
|
77
|
-
data.each do |stack|
|
78
|
-
row1 = true
|
79
|
-
parameter_output += delim
|
80
|
-
delim="\n"
|
81
|
-
parameter_output+=stack["StackName"] + ": "
|
82
|
-
|
83
|
-
stack["Outputs"].each do |output|
|
84
|
-
if !row1
|
85
|
-
|
86
|
-
parameter_output += ";"
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
parameter_output += output["OutputKey"] + "=" + output["OutputValue"]
|
92
|
-
row1 = false
|
93
|
-
end
|
94
|
-
end
|
95
|
-
if locate_config_value(:output_format) == "parameter"
|
96
|
-
puts parameter_output
|
97
|
-
else
|
98
|
-
puts ui.list(
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
require 'chef/knife'
|
16
|
+
require 'chef/knife/cfn_base'
|
17
|
+
|
18
|
+
class Chef
|
19
|
+
class Knife
|
20
|
+
class CfnOutputs < Chef::Knife::CfnBase
|
21
|
+
|
22
|
+
deps do
|
23
|
+
require 'fog'
|
24
|
+
require 'readline'
|
25
|
+
require 'chef/json_compat'
|
26
|
+
require 'chef/knife/bootstrap'
|
27
|
+
Chef::Knife::Bootstrap.load_deps
|
28
|
+
end
|
29
|
+
|
30
|
+
banner "knife cfn outputs <stack name>"
|
31
|
+
|
32
|
+
option :output_parameter_format,
|
33
|
+
:short => "-o",
|
34
|
+
:long => "--output_parameter_format",
|
35
|
+
:description => "Stack output is formatted in a suitable syntax to use for parameters for another stack",
|
36
|
+
:proc => Proc.new{ |o| Chef::Config[:knife][:output_format] = "parameter" }
|
37
|
+
|
38
|
+
def run
|
39
|
+
$stdout.sync = true
|
40
|
+
|
41
|
+
validate!
|
42
|
+
|
43
|
+
stack_name = @name_args[0]
|
44
|
+
if stack_name.nil?
|
45
|
+
show_usage
|
46
|
+
ui.error("You must specify a stack name")
|
47
|
+
exit 1
|
48
|
+
end
|
49
|
+
|
50
|
+
outputs_list = [
|
51
|
+
ui.color("Stack", :bold),
|
52
|
+
ui.color('Output Key', :bold),
|
53
|
+
ui.color('Output Value', :bold),
|
54
|
+
ui.color('Description', :bold)
|
55
|
+
]
|
56
|
+
|
57
|
+
@name_args.each do |stack_name|
|
58
|
+
options = {}
|
59
|
+
options["StackName"] = stack_name
|
60
|
+
data = Array.new
|
61
|
+
begin
|
62
|
+
response = connection.describe_stacks(options)
|
63
|
+
data = response.body["Stacks"]
|
64
|
+
|
65
|
+
rescue Excon::Errors::BadRequest => e
|
66
|
+
i= e.response.body.index("<Message>")
|
67
|
+
j = e.response.body.index("</Message>")
|
68
|
+
if !i.nil? and !j.nil?
|
69
|
+
ui.error(e.response.body[i+9,j-i-9])
|
70
|
+
else
|
71
|
+
print "\n#{e.response.body}"
|
72
|
+
end
|
73
|
+
exit 1
|
74
|
+
else
|
75
|
+
parameter_output=""
|
76
|
+
delim=""
|
77
|
+
data.each do |stack|
|
78
|
+
row1 = true
|
79
|
+
parameter_output += delim
|
80
|
+
delim="\n"
|
81
|
+
parameter_output+=stack["StackName"] + ": "
|
82
|
+
outputs_list << stack["StackName"]
|
83
|
+
stack["Outputs"].each do |output|
|
84
|
+
if !row1
|
85
|
+
outputs_list << ""
|
86
|
+
parameter_output += ";"
|
87
|
+
end
|
88
|
+
outputs_list << output["OutputKey"]
|
89
|
+
outputs_list << output["OutputValue"]
|
90
|
+
outputs_list << output["Description"]
|
91
|
+
parameter_output += output["OutputKey"] + "=" + output["OutputValue"]
|
92
|
+
row1 = false
|
93
|
+
end
|
94
|
+
end
|
95
|
+
if locate_config_value(:output_format) == "parameter"
|
96
|
+
puts parameter_output
|
97
|
+
else
|
98
|
+
puts ui.list(outputs_list, :uneven_columns_across, 4)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
require 'chef/knife'
|
16
|
+
require 'chef/knife/cfn_base'
|
17
|
+
|
18
|
+
class Chef
|
19
|
+
class Knife
|
20
|
+
class CfnResources < Chef::Knife::CfnBase
|
21
|
+
|
22
|
+
deps do
|
23
|
+
require 'fog'
|
24
|
+
require 'readline'
|
25
|
+
require 'chef/json_compat'
|
26
|
+
require 'chef/knife/bootstrap'
|
27
|
+
Chef::Knife::Bootstrap.load_deps
|
28
|
+
end
|
29
|
+
|
30
|
+
banner "knife cfn resources <stack name> [logical resource id]"
|
31
|
+
|
32
|
+
def run
|
33
|
+
$stdout.sync = true
|
34
|
+
|
35
|
+
validate!
|
36
|
+
|
37
|
+
stack_name = @name_args[0]
|
38
|
+
logical_resource_id = @name_args[1]
|
39
|
+
|
40
|
+
if stack_name.nil?
|
41
|
+
show_usage
|
42
|
+
ui.error("You must specify a stack name")
|
43
|
+
exit 1
|
44
|
+
end
|
45
|
+
|
46
|
+
resources_list = [
|
47
|
+
ui.color('Logical Resource Id', :bold),
|
48
|
+
ui.color('Physical Resource Id', :bold),
|
49
|
+
ui.color('Resource Type', :bold),
|
50
|
+
ui.color('Resource Status', :bold)
|
51
|
+
]
|
52
|
+
|
53
|
+
connection_params = { "StackName" => stack_name }
|
54
|
+
if !logical_resource_id.nil?
|
55
|
+
connection_params["LogicalResourceId"] = logical_resource_id
|
56
|
+
end
|
57
|
+
|
58
|
+
data = Array.new
|
59
|
+
begin
|
60
|
+
response = connection.describe_stack_resources(connection_params)
|
61
|
+
data = response.body['StackResources']
|
62
|
+
rescue Excon::Errors::BadRequest => e
|
63
|
+
i= e.response.body.index("<Message>")
|
64
|
+
j = e.response.body.index("</Message>")
|
65
|
+
if !i.nil? and !j.nil?
|
66
|
+
ui.error(e.response.body[i+9,j-i-9])
|
67
|
+
else
|
68
|
+
print "\n#{e.response.body}"
|
69
|
+
end
|
70
|
+
exit 1
|
71
|
+
else
|
72
|
+
data.each do |resource|
|
73
|
+
resources_list << resource['LogicalResourceId']
|
74
|
+
resources_list << resource['PhysicalResourceId']
|
75
|
+
resources_list << resource['ResourceType']
|
76
|
+
resources_list << resource['ResourceStatus']
|
77
|
+
end
|
78
|
+
puts ui.list(resources_list, :uneven_columns_across, 4)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-cfn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -55,9 +55,10 @@ files:
|
|
55
55
|
- lib/chef/knife/cfn_describe.rb
|
56
56
|
- lib/chef/knife/cfn_events.rb
|
57
57
|
- lib/chef/knife/cfn_outputs.rb
|
58
|
+
- lib/chef/knife/cfn_resources.rb
|
58
59
|
- lib/chef/knife/cfn_update.rb
|
59
60
|
- lib/chef/knife/cfn_validate.rb
|
60
|
-
- lib/knife-
|
61
|
+
- lib/knife-cfn/version.rb
|
61
62
|
homepage: https://github.com/neillturner/knife-cfn
|
62
63
|
licenses: []
|
63
64
|
post_install_message:
|
data/lib/knife-cnf/version.rb
DELETED