Sha256: b80aa34cac6ee30793f03734e6dc1f1c0287daa03fc59cf2ddc3560eb63e1163

Contents?: true

Size: 1.07 KB

Versions: 136

Compression:

Stored size: 1.07 KB

Contents

# CloudFormation SNS TopicPolicy docs: https://amzn.to/2SBMq9v
module Jets::Resource::Sns
  class TopicPolicy < Jets::Resource::Base
    def initialize(props={})
      @props = props # associated_properties from dsl.rb
    end

    def definition
      {
        policy_logical_id => {
          type: "AWS::SNS::TopicPolicy",
          properties: merged_properties,
        }
      }
    end

    # Do not name this method properties, that is a computed method of `Jets::Resource::Base`
    def merged_properties
      {
        policy_document: {
          version: "2012-10-17",
          statement: {
            effect: "Allow",
            principal: { service: "s3.amazonaws.com"},
            action: "sns:Publish",
            resource: "*", # TODO: figure out good syntax to limit easily
            # Condition:
            #   ArnLike:
            #     aws:SourceArn: arn:aws:s3:::aa-test-95872017
          }
        },
        topics: ["!Ref {namespace}SnsTopic"],
      }.deep_merge(@props)
    end

    def policy_logical_id
      "{namespace}_sns_topic_policy"
    end
  end
end

Version data entries

136 entries across 136 versions & 3 rubygems

Version Path
jets-1.9.20 lib/jets/resource/sns/topic_policy.rb
jets-1.9.19 lib/jets/resource/sns/topic_policy.rb
jets-1.9.18 lib/jets/resource/sns/topic_policy.rb
jets-1.9.17 lib/jets/resource/sns/topic_policy.rb
jets-1.9.16 lib/jets/resource/sns/topic_policy.rb
jets-1.9.15 lib/jets/resource/sns/topic_policy.rb
jets-1.9.14 lib/jets/resource/sns/topic_policy.rb
jets-1.9.13 lib/jets/resource/sns/topic_policy.rb
jets-1.9.12 lib/jets/resource/sns/topic_policy.rb
jets-1.9.11 lib/jets/resource/sns/topic_policy.rb
jets-1.9.10 lib/jets/resource/sns/topic_policy.rb
jets-1.9.9 lib/jets/resource/sns/topic_policy.rb
jets-1.9.8 lib/jets/resource/sns/topic_policy.rb
jets-1.9.7 lib/jets/resource/sns/topic_policy.rb
jets-1.9.6 lib/jets/resource/sns/topic_policy.rb
jets-1.9.5 lib/jets/resource/sns/topic_policy.rb
jets-1.9.4 lib/jets/resource/sns/topic_policy.rb
jets-1.9.3 lib/jets/resource/sns/topic_policy.rb
jets-1.9.2 lib/jets/resource/sns/topic_policy.rb
jets-1.9.1 lib/jets/resource/sns/topic_policy.rb