Class: Jets::Cfn::Resource::Sns::TopicPolicy

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/cfn/resource/sns/topic_policy.rb

Instance Method Summary collapse

Methods inherited from Base

#attributes, #logical_id, #outputs, #parameters, #permission, #properties, #replacements, #replacer, #standarize, #template, truncate_id, #type

Methods included from Util::Camelize

#camelize

Constructor Details

#initialize(props = {}) ⇒ TopicPolicy

Returns a new instance of TopicPolicy.



4
5
6
# File 'lib/jets/cfn/resource/sns/topic_policy.rb', line 4

def initialize(props={})
  @props = props # associated_properties from dsl.rb
end

Instance Method Details

#definitionObject



8
9
10
11
12
13
14
15
# File 'lib/jets/cfn/resource/sns/topic_policy.rb', line 8

def definition
  {
    policy_logical_id => {
      Type: "AWS::SNS::TopicPolicy",
      Properties: merged_properties,
    }
  }
end

#merged_propertiesObject

Do not name this method properties, that is a computed method of ‘Jets::Cfn::Resource`



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jets/cfn/resource/sns/topic_policy.rb', line 18

def merged_properties
  {
    PolicyDocument: {
      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

#policy_logical_idObject



36
37
38
# File 'lib/jets/cfn/resource/sns/topic_policy.rb', line 36

def policy_logical_id
  "{namespace}SnsTopicPolicy"
end