Class: Jets::Resource::Sns::Topic

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

Instance Method Summary collapse

Methods inherited from Base

#replacements, #resource

Constructor Details

#initialize(props = {}) ⇒ Topic

Returns a new instance of Topic.



4
5
6
# File 'lib/jets/resource/sns/topic.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/resource/sns/topic.rb', line 8

def definition
  {
    topic_logical_id => {
      type: "AWS::SNS::Topic",
      properties: merged_properties,
    }
  }
end

#merged_propertiesObject

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



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/jets/resource/sns/topic.rb', line 18

def merged_properties
  display_name = "{namespace} Topic"[0..99] # limit is 100 chars
  {
    display_name: display_name,
    # Not setting subscription this way but instead with a SNS::Subscription resource so the interface
    # is consistent. Leaving comment in here to remind me and in case decide to change this.
    # subscription: [
    #   endpoint: "!GetAtt {namespace}LambdaFunction.Arn",
    #   protocol: "lambda"
    # ]
  }.deep_merge(@props)
end

#topic_logical_idObject



31
32
33
# File 'lib/jets/resource/sns/topic.rb', line 31

def topic_logical_id
  "{namespace}_sns_topic"
end