class Chef::Handler::Sns::Config::Ohai
Gets Chef
Handler
SNS default configuration from [Ohai](docs.chef.io/ohai.html) information.
Attributes
AWS access key.
@return [String] Access key.
AWS region name.
Not used, read from the topic ARN.
@return [String] Region.
AWS secret key.
@return [String] Secret key.
AWS token.
@return [String] token.
Public Class Methods
Constructs a {Chef::Handler::Sns::Config::Ohai} object.
@param node [Chef::Node] Node object to read Ohai
information from.
@api public
# File lib/chef/handler/sns/config/ohai.rb, line 66 def initialize(node) read_config(node) end
Protected Instance Methods
Reads configuration information from Ohai
.
Reads both region information and IAM credentials.
@param node [Chef::Node] Node object to read information from.
@return void
@api private
# File lib/chef/handler/sns/config/ohai.rb, line 121 def read_config(node) return unless node.attribute?('ec2') read_region_config(node['ec2']) read_iam_config(node['ec2']) end
Reads the IAM credentials from Ohai
.
@param ec2 [Hash] These are attributes below `node`.
@return void
@api private
# File lib/chef/handler/sns/config/ohai.rb, line 99 def read_iam_config(ec2) return unless ec2.attribute?('iam') && ec2['iam'].attribute?('security-credentials') _iam_role, credentials = ec2['iam']['security-credentials'].to_hash.first return if credentials.nil? @access_key = credentials['AccessKeyId'] @secret_key = credentials['SecretAccessKey'] @token = credentials['Token'] end
Reads AWS region information from Ohai
.
Old code. This is currently not used. We are reading region information from Topic ARN.
@param ec2 [Hash] These are attributes below `node`.
@return void
@api private
# File lib/chef/handler/sns/config/ohai.rb, line 84 def read_region_config(ec2) return unless ec2.attribute?('placement_availability_zone') && ec2['placement_availability_zone'].is_a?(String) @region = ec2['placement_availability_zone'].chop end