knife-cfn 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/chef/knife/cfn_base.rb +101 -16
- data/lib/chef/knife/cfn_create.rb +125 -125
- data/lib/chef/knife/cfn_delete.rb +61 -21
- data/lib/chef/knife/cfn_describe.rb +40 -0
- data/lib/chef/knife/cfn_events.rb +53 -13
- data/lib/chef/knife/cfn_outputs.rb +148 -108
- data/lib/chef/knife/cfn_resources.rb +126 -86
- data/lib/chef/knife/cfn_update.rb +66 -26
- data/lib/chef/knife/cfn_validate.rb +55 -16
- data/lib/knife-cfn/version.rb +3 -3
- metadata +13 -19
@@ -34,6 +34,46 @@ class Chef
|
|
34
34
|
:long => "--long",
|
35
35
|
:description => "Use long stack names (ARN) instead of friendly names"
|
36
36
|
|
37
|
+
option :aws_credential_file,
|
38
|
+
:long => "--aws-credential-file FILE",
|
39
|
+
:description => "File containing AWS credentials as used by aws cmdline tools",
|
40
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_credential_file] = key }
|
41
|
+
|
42
|
+
option :aws_profile,
|
43
|
+
:long => "--aws-profile PROFILE",
|
44
|
+
:description => "AWS profile, from credential file, to use",
|
45
|
+
:default => 'default',
|
46
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_profile] = key }
|
47
|
+
|
48
|
+
option :aws_access_key_id,
|
49
|
+
:short => "-A ID",
|
50
|
+
:long => "--aws-access-key-id KEY",
|
51
|
+
:description => "Your AWS Access Key ID",
|
52
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_access_key_id] = key }
|
53
|
+
|
54
|
+
option :aws_secret_access_key,
|
55
|
+
:short => "-K SECRET",
|
56
|
+
:long => "--aws-secret-access-key SECRET",
|
57
|
+
:description => "Your AWS API Secret Access Key",
|
58
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_secret_access_key] = key }
|
59
|
+
|
60
|
+
option :aws_session_token,
|
61
|
+
:long => "--aws-session-token TOKEN",
|
62
|
+
:description => "Your AWS Session Token, for use with AWS STS Federation or Session Tokens",
|
63
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_session_token] = key }
|
64
|
+
|
65
|
+
option :region,
|
66
|
+
:long => "--region REGION",
|
67
|
+
:description => "Your AWS region",
|
68
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:region] = key }
|
69
|
+
|
70
|
+
option :use_iam_profile,
|
71
|
+
:long => "--use-iam-profile",
|
72
|
+
:description => "Use IAM profile assigned to current machine",
|
73
|
+
:boolean => true,
|
74
|
+
:default => false,
|
75
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:use_iam_profile] = key }
|
76
|
+
|
37
77
|
def run
|
38
78
|
$stdout.sync = true
|
39
79
|
|
@@ -18,29 +18,69 @@ require 'chef/knife/cfn_base'
|
|
18
18
|
class Chef
|
19
19
|
class Knife
|
20
20
|
class CfnEvents < Chef::Knife::CfnBase
|
21
|
-
|
21
|
+
|
22
22
|
deps do
|
23
23
|
require 'fog'
|
24
24
|
require 'readline'
|
25
25
|
require 'chef/json_compat'
|
26
26
|
require 'chef/knife/bootstrap'
|
27
27
|
Chef::Knife::Bootstrap.load_deps
|
28
|
-
end
|
28
|
+
end
|
29
29
|
|
30
30
|
banner "knife cfn events <stack name>"
|
31
31
|
|
32
|
+
option :aws_credential_file,
|
33
|
+
:long => "--aws-credential-file FILE",
|
34
|
+
:description => "File containing AWS credentials as used by aws cmdline tools",
|
35
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_credential_file] = key }
|
36
|
+
|
37
|
+
option :aws_profile,
|
38
|
+
:long => "--aws-profile PROFILE",
|
39
|
+
:description => "AWS profile, from credential file, to use",
|
40
|
+
:default => 'default',
|
41
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_profile] = key }
|
42
|
+
|
43
|
+
option :aws_access_key_id,
|
44
|
+
:short => "-A ID",
|
45
|
+
:long => "--aws-access-key-id KEY",
|
46
|
+
:description => "Your AWS Access Key ID",
|
47
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_access_key_id] = key }
|
48
|
+
|
49
|
+
option :aws_secret_access_key,
|
50
|
+
:short => "-K SECRET",
|
51
|
+
:long => "--aws-secret-access-key SECRET",
|
52
|
+
:description => "Your AWS API Secret Access Key",
|
53
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_secret_access_key] = key }
|
54
|
+
|
55
|
+
option :aws_session_token,
|
56
|
+
:long => "--aws-session-token TOKEN",
|
57
|
+
:description => "Your AWS Session Token, for use with AWS STS Federation or Session Tokens",
|
58
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_session_token] = key }
|
59
|
+
|
60
|
+
option :region,
|
61
|
+
:long => "--region REGION",
|
62
|
+
:description => "Your AWS region",
|
63
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:region] = key }
|
64
|
+
|
65
|
+
option :use_iam_profile,
|
66
|
+
:long => "--use-iam-profile",
|
67
|
+
:description => "Use IAM profile assigned to current machine",
|
68
|
+
:boolean => true,
|
69
|
+
:default => false,
|
70
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:use_iam_profile] = key }
|
71
|
+
|
32
72
|
def run
|
33
73
|
$stdout.sync = true
|
34
74
|
|
35
75
|
validate!
|
36
|
-
|
76
|
+
|
37
77
|
stack_name = @name_args[0]
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
78
|
+
|
79
|
+
if stack_name.nil?
|
80
|
+
show_usage
|
81
|
+
ui.error("You must specify a stack name")
|
82
|
+
exit 1
|
83
|
+
end
|
44
84
|
|
45
85
|
events_list = [
|
46
86
|
ui.color('Event ID', :bold),
|
@@ -53,12 +93,12 @@ class Chef
|
|
53
93
|
ui.color('Resource Status Reason', :bold)
|
54
94
|
]
|
55
95
|
@name_args.each do |stack_name|
|
56
|
-
|
57
|
-
|
96
|
+
data = Array.new
|
97
|
+
begin
|
58
98
|
response = connection.describe_stack_events(stack_name)
|
59
99
|
data = response.body['StackEvents']
|
60
100
|
rescue Excon::Errors::BadRequest => e
|
61
|
-
|
101
|
+
i= e.response.body.index("<Message>")
|
62
102
|
j = e.response.body.index("</Message>")
|
63
103
|
if !i.nil? and !j.nil?
|
64
104
|
ui.error(e.response.body[i+9,j-i-9])
|
@@ -67,7 +107,7 @@ class Chef
|
|
67
107
|
end
|
68
108
|
exit 1
|
69
109
|
else
|
70
|
-
|
110
|
+
data.each do |event|
|
71
111
|
events_list << event['EventId']
|
72
112
|
events_list << event['StackId']
|
73
113
|
events_list << event['LogicalResourceId']
|
@@ -1,108 +1,148 @@
|
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
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
|
+
option :aws_credential_file,
|
39
|
+
:long => "--aws-credential-file FILE",
|
40
|
+
:description => "File containing AWS credentials as used by aws cmdline tools",
|
41
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_credential_file] = key }
|
42
|
+
|
43
|
+
option :aws_profile,
|
44
|
+
:long => "--aws-profile PROFILE",
|
45
|
+
:description => "AWS profile, from credential file, to use",
|
46
|
+
:default => 'default',
|
47
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_profile] = key }
|
48
|
+
|
49
|
+
option :aws_access_key_id,
|
50
|
+
:short => "-A ID",
|
51
|
+
:long => "--aws-access-key-id KEY",
|
52
|
+
:description => "Your AWS Access Key ID",
|
53
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_access_key_id] = key }
|
54
|
+
|
55
|
+
option :aws_secret_access_key,
|
56
|
+
:short => "-K SECRET",
|
57
|
+
:long => "--aws-secret-access-key SECRET",
|
58
|
+
:description => "Your AWS API Secret Access Key",
|
59
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_secret_access_key] = key }
|
60
|
+
|
61
|
+
option :aws_session_token,
|
62
|
+
:long => "--aws-session-token TOKEN",
|
63
|
+
:description => "Your AWS Session Token, for use with AWS STS Federation or Session Tokens",
|
64
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_session_token] = key }
|
65
|
+
|
66
|
+
option :region,
|
67
|
+
:long => "--region REGION",
|
68
|
+
:description => "Your AWS region",
|
69
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:region] = key }
|
70
|
+
|
71
|
+
option :use_iam_profile,
|
72
|
+
:long => "--use-iam-profile",
|
73
|
+
:description => "Use IAM profile assigned to current machine",
|
74
|
+
:boolean => true,
|
75
|
+
:default => false,
|
76
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:use_iam_profile] = key }
|
77
|
+
|
78
|
+
def run
|
79
|
+
$stdout.sync = true
|
80
|
+
|
81
|
+
validate!
|
82
|
+
|
83
|
+
stack_name = @name_args[0]
|
84
|
+
if stack_name.nil?
|
85
|
+
show_usage
|
86
|
+
ui.error("You must specify a stack name")
|
87
|
+
exit 1
|
88
|
+
end
|
89
|
+
|
90
|
+
outputs_list = [
|
91
|
+
ui.color("Stack", :bold),
|
92
|
+
ui.color('Output Key', :bold),
|
93
|
+
ui.color('Output Value', :bold),
|
94
|
+
ui.color('Description', :bold)
|
95
|
+
]
|
96
|
+
|
97
|
+
@name_args.each do |stack_name|
|
98
|
+
options = {}
|
99
|
+
options["StackName"] = stack_name
|
100
|
+
data = Array.new
|
101
|
+
begin
|
102
|
+
response = connection.describe_stacks(options)
|
103
|
+
data = response.body["Stacks"]
|
104
|
+
|
105
|
+
rescue Excon::Errors::BadRequest => e
|
106
|
+
i= e.response.body.index("<Message>")
|
107
|
+
j = e.response.body.index("</Message>")
|
108
|
+
if !i.nil? and !j.nil?
|
109
|
+
ui.error(e.response.body[i+9,j-i-9])
|
110
|
+
else
|
111
|
+
print "\n#{e.response.body}"
|
112
|
+
end
|
113
|
+
exit 1
|
114
|
+
else
|
115
|
+
parameter_output=""
|
116
|
+
delim=""
|
117
|
+
data.each do |stack|
|
118
|
+
row1 = true
|
119
|
+
parameter_output += delim
|
120
|
+
delim="\n"
|
121
|
+
parameter_output+=stack["StackName"] + ": "
|
122
|
+
outputs_list << stack["StackName"]
|
123
|
+
stack["Outputs"].each do |output|
|
124
|
+
if !row1
|
125
|
+
outputs_list << ""
|
126
|
+
parameter_output += ";"
|
127
|
+
end
|
128
|
+
outputs_list << output["OutputKey"]
|
129
|
+
outputs_list << output["OutputValue"]
|
130
|
+
outputs_list << output["Description"]
|
131
|
+
parameter_output += output["OutputKey"] + "=" + output["OutputValue"]
|
132
|
+
row1 = false
|
133
|
+
end
|
134
|
+
end
|
135
|
+
if locate_config_value(:output_format) == "parameter"
|
136
|
+
puts parameter_output
|
137
|
+
else
|
138
|
+
puts ui.list(outputs_list, :uneven_columns_across, 4)
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
|
@@ -1,86 +1,126 @@
|
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
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
|
+
option :aws_credential_file,
|
33
|
+
:long => "--aws-credential-file FILE",
|
34
|
+
:description => "File containing AWS credentials as used by aws cmdline tools",
|
35
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_credential_file] = key }
|
36
|
+
|
37
|
+
option :aws_profile,
|
38
|
+
:long => "--aws-profile PROFILE",
|
39
|
+
:description => "AWS profile, from credential file, to use",
|
40
|
+
:default => 'default',
|
41
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_profile] = key }
|
42
|
+
|
43
|
+
option :aws_access_key_id,
|
44
|
+
:short => "-A ID",
|
45
|
+
:long => "--aws-access-key-id KEY",
|
46
|
+
:description => "Your AWS Access Key ID",
|
47
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_access_key_id] = key }
|
48
|
+
|
49
|
+
option :aws_secret_access_key,
|
50
|
+
:short => "-K SECRET",
|
51
|
+
:long => "--aws-secret-access-key SECRET",
|
52
|
+
:description => "Your AWS API Secret Access Key",
|
53
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_secret_access_key] = key }
|
54
|
+
|
55
|
+
option :aws_session_token,
|
56
|
+
:long => "--aws-session-token TOKEN",
|
57
|
+
:description => "Your AWS Session Token, for use with AWS STS Federation or Session Tokens",
|
58
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:aws_session_token] = key }
|
59
|
+
|
60
|
+
option :region,
|
61
|
+
:long => "--region REGION",
|
62
|
+
:description => "Your AWS region",
|
63
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:region] = key }
|
64
|
+
|
65
|
+
option :use_iam_profile,
|
66
|
+
:long => "--use-iam-profile",
|
67
|
+
:description => "Use IAM profile assigned to current machine",
|
68
|
+
:boolean => true,
|
69
|
+
:default => false,
|
70
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:use_iam_profile] = key }
|
71
|
+
|
72
|
+
def run
|
73
|
+
$stdout.sync = true
|
74
|
+
|
75
|
+
validate!
|
76
|
+
|
77
|
+
stack_name = @name_args[0]
|
78
|
+
logical_resource_id = @name_args[1]
|
79
|
+
|
80
|
+
if stack_name.nil?
|
81
|
+
show_usage
|
82
|
+
ui.error("You must specify a stack name")
|
83
|
+
exit 1
|
84
|
+
end
|
85
|
+
|
86
|
+
resources_list = [
|
87
|
+
ui.color('Logical Resource Id', :bold),
|
88
|
+
ui.color('Physical Resource Id', :bold),
|
89
|
+
ui.color('Resource Type', :bold),
|
90
|
+
ui.color('Resource Status', :bold)
|
91
|
+
]
|
92
|
+
|
93
|
+
connection_params = { "StackName" => stack_name }
|
94
|
+
if !logical_resource_id.nil?
|
95
|
+
connection_params["LogicalResourceId"] = logical_resource_id
|
96
|
+
end
|
97
|
+
|
98
|
+
data = Array.new
|
99
|
+
begin
|
100
|
+
response = connection.describe_stack_resources(connection_params)
|
101
|
+
data = response.body['StackResources']
|
102
|
+
rescue Excon::Errors::BadRequest => e
|
103
|
+
i= e.response.body.index("<Message>")
|
104
|
+
j = e.response.body.index("</Message>")
|
105
|
+
if !i.nil? and !j.nil?
|
106
|
+
ui.error(e.response.body[i+9,j-i-9])
|
107
|
+
else
|
108
|
+
print "\n#{e.response.body}"
|
109
|
+
end
|
110
|
+
exit 1
|
111
|
+
else
|
112
|
+
data.each do |resource|
|
113
|
+
resources_list << resource['LogicalResourceId']
|
114
|
+
resources_list << resource['PhysicalResourceId']
|
115
|
+
resources_list << resource['ResourceType']
|
116
|
+
resources_list << resource['ResourceStatus']
|
117
|
+
end
|
118
|
+
puts ui.list(resources_list, :uneven_columns_across, 4)
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|