libraries/helper.rb
# sends an SNS notification when a vault item cannot be decrypted
# @param node [Chef::Node] the chef node object
# @param state [Struct] the state of the attempt to decrypt the vault items
# @param opts [Hash] options
# @option opts [String] :topic the SNS topic
# @option opts [String] :region the AWS region.  Defaults to the value from Ohai data
# @option opts [String] :credentials the AWS credentials to use
# @return [void]
sends an SNS notification when a vault item cannot be decrypted
sends an SNS notification when a vault item cannot be decrypted
def sns_notify(node, state, opts)
      require 'aws-sdk'
      begin
        opts[:region] ||= az_from_placement(node['ec2']['placement_availability_zone'])
        args = { region: opts[:region] }
        args[:credentials] = opts[:credentials] if opts.key?(:credentials)
        client = Aws::SNS::Client.new(args)
        resp = client.publish(
          topic_arn: opts[:topic],
          message: notification_json(node, state)
        )
        Chef::Log.info "notified #{opts[:topic]} with message id #{resp[:message_id]}"
      rescue Aws::SNS::Errors::ServiceError => e
        Chef::Log.warn "unable to send SNS notification: #{e}"
      end
    end
def sns_notify ( node , state , opts ) require 'aws-sdk' begin opts [ :region ] ||= az_from_placement ( node [ 'ec2' ] [ 'placement_availability_zone' ] ) args = { region : opts [ :region ] } args [ :credentials ] = opts [ :credentials ] if opts . key? ( :credentials ) client = Aws :: SNS :: Client . new ( args ) resp = client . publish ( topic_arn : opts [ :topic ] , message : notification_json ( node , state ) ) Chef :: Log . info "notified #{opts[:topic]} with message id #{resp[:message_id]}" rescue Aws :: SNS :: Errors :: ServiceError => e Chef :: Log . warn "unable to send SNS notification: #{e}" end end
sends an SNS notification when a vault item cannot be decrypted
sends an SNS notification when a vault item cannot be decrypted
None
void
node
the chef node object
the chef node object
state
the state of the attempt to decrypt the vault items
the state of the attempt to decrypt the vault items
opts
:credentials the AWS credentials to use
: credentials the AWS credentials to use