This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from brettcave/cloudformation-resources
Cloudformation resource listing
- Loading branch information
Showing
9 changed files
with
113 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require 'chef/knife' | ||
require 'chef/knife/cfn_base' | ||
|
||
class Chef | ||
class Knife | ||
class CfnResources < Chef::Knife::CfnBase | ||
|
||
deps do | ||
require 'fog' | ||
require 'readline' | ||
require 'chef/json_compat' | ||
require 'chef/knife/bootstrap' | ||
Chef::Knife::Bootstrap.load_deps | ||
end | ||
|
||
banner "knife cfn resources <stack name> [logical resource id]" | ||
|
||
def run | ||
$stdout.sync = true | ||
|
||
validate! | ||
|
||
stack_name = @name_args[0] | ||
logical_resource_id = @name_args[1] | ||
|
||
if stack_name.nil? | ||
show_usage | ||
ui.error("You must specify a stack name") | ||
exit 1 | ||
end | ||
|
||
resources_list = [ | ||
ui.color('Logical Resource Id', :bold), | ||
ui.color('Physical Resource Id', :bold), | ||
ui.color('Resource Type', :bold), | ||
ui.color('Resource Status', :bold) | ||
] | ||
|
||
connection_params = { "StackName" => stack_name } | ||
if !logical_resource_id.nil? | ||
connection_params["LogicalResourceId"] = logical_resource_id | ||
end | ||
|
||
data = Array.new | ||
begin | ||
response = connection.describe_stack_resources(connection_params) | ||
data = response.body['StackResources'] | ||
rescue Excon::Errors::BadRequest => e | ||
i= e.response.body.index("<Message>") | ||
j = e.response.body.index("</Message>") | ||
if !i.nil? and !j.nil? | ||
ui.error(e.response.body[i+9,j-i-9]) | ||
else | ||
print "\n#{e.response.body}" | ||
end | ||
exit 1 | ||
else | ||
data.each do |resource| | ||
resources_list << resource['LogicalResourceId'] | ||
resources_list << resource['PhysicalResourceId'] | ||
resources_list << resource['ResourceType'] | ||
resources_list << resource['ResourceStatus'] | ||
end | ||
puts ui.list(resources_list, :uneven_columns_across, 4) | ||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module KnifeCfn | ||
VERSION = "0.1.10" | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
$:.unshift File.expand_path('../../lib', __FILE__) | ||
require 'chef' | ||
require 'knife-cnf/cfn_base' | ||
require 'knife-cnf/cfn_create' | ||
require 'knife-cnf/cfn_delete' | ||
require 'knife-cnf/cfn_describe' | ||
require 'knife-cnf/cfn_events' | ||
require 'knife-cnf/cfn_outputs' | ||
require 'knife-cnf/cfn_validate' | ||
require 'knife-cfn/cfn_base' | ||
require 'knife-cfn/cfn_create' | ||
require 'knife-cfn/cfn_delete' | ||
require 'knife-cfn/cfn_describe' | ||
require 'knife-cfn/cfn_events' | ||
require 'knife-cfn/cfn_resources' | ||
require 'knife-cfn/cfn_outputs' | ||
require 'knife-cfn/cfn_validate' | ||
|