Sha256: 2b55744ba5db684913478190ee77df001c1284967019a880b203f214eb96e675

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

require "cloud_shaped/core_methods"

module CloudShaped
  # Methods to create sns topics
  module SnsMethods
    include CoreMethods

    def sns_topic(endpoint)
      proto, target = sns_proto_target(endpoint)
      resource "AWS::SNS::Topic", "Subscription" => [
        { "Protocol" => proto, "Endpoint" => target }
      ]
    end

    private

    def sns_proto_target(target)
      case target
      when /^(https?):/
        [Regexp.last_match[1].upcase, target]
      when /^(mailto):(.*)/
        ["email", Regexp.last_match[2]]
      else ["email", target]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloud_shaped-1.1.0 lib/cloud_shaped/sns_methods.rb