Class: Pipedream::Sns

Inherits:
Object
  • Object
show all
Includes:
Dsl::Sns, Evaluate
Defined in:
lib/pipedream/sns.rb

Constant Summary

Constants included from Dsl::Sns

Dsl::Sns::PROPERTIES

Instance Method Summary collapse

Methods included from Evaluate

#evaluate

Constructor Details

#initialize(options = {}) ⇒ Sns

Returns a new instance of Sns.



6
7
8
9
10
# File 'lib/pipedream/sns.rb', line 6

def initialize(options={})
  @options = options
  @sns_path = options[:sns_path] || get_sns_path
  @properties = default_properties
end

Instance Method Details

#default_propertiesObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pipedream/sns.rb', line 24

def default_properties
  display_name = "#{@options[:full_pipeline_name]} pipeline"
  {
    display_name: display_name,
    # kms_master_key_id: "string",
    # subscription: [{
    #   endpoint: '',
    #   protocol: ','
    # }],
    # topic_name: "string", # Not setting because update requires: Replacement. Dont want 2 pipelines to collide
  }
  # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-subscription.html
end

#runObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pipedream/sns.rb', line 12

def run
  evaluate(@sns_path) if File.exist?(@sns_path)

  resource = {
    sns_topic: {
      type: "AWS::SNS::Topic",
      properties: @properties
    }
  }
  CfnCamelizer.transform(resource)
end