Sha256: 68514a1e5291c0a78e47096b3ebd33fbfb5aaae77b89ecc63ee848e6e67ee6f6

Contents?: true

Size: 640 Bytes

Versions: 11

Compression:

Stored size: 640 Bytes

Contents

require 'aws-sdk'

class AwsSns < Oxidized::Hook
  def validate_cfg!
    raise KeyError, 'hook.region is required' unless cfg.has_key?('region')
    raise KeyError, 'hook.topic_arn is required' unless cfg.has_key?('topic_arn')
  end

  def run_hook(ctx)
    sns = Aws::SNS::Resource.new(region: cfg.region)
    topic = sns.topic(cfg.topic_arn)
    message = {
      event: ctx.event.to_s
    }
    if ctx.node
      message.merge!(
        group: ctx.node.group.to_s,
        model: ctx.node.model.class.name.to_s.downcase,
        node:  ctx.node.name.to_s
      )
    end
    topic.publish(
      message: message.to_json
    )
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
oxidized-0.31.0 lib/oxidized/hook/awssns.rb
oxidized-0.30.1 lib/oxidized/hook/awssns.rb
oxidized-0.30.0 lib/oxidized/hook/awssns.rb
oxidized-0.29.1 lib/oxidized/hook/awssns.rb
oxidized-0.29.0 lib/oxidized/hook/awssns.rb
oxidized-0.28.0 lib/oxidized/hook/awssns.rb
oxidized-0.27.0 lib/oxidized/hook/awssns.rb
oxidized-0.26.3 lib/oxidized/hook/awssns.rb
oxidized-0.26.2 lib/oxidized/hook/awssns.rb
oxidized-0.26.1 lib/oxidized/hook/awssns.rb
oxidized-0.26.0 lib/oxidized/hook/awssns.rb