Class: Terrafying::Components::Security::PagerdutyTopic

Inherits:
Terrafying::Context
  • Object
show all
Defined in:
lib/terrafying/components/security/pagerduty_topic.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arnObject (readonly)

Returns the value of attribute arn.



13
14
15
# File 'lib/terrafying/components/security/pagerduty_topic.rb', line 13

def arn
  @arn
end

Class Method Details

.create(*args) ⇒ Object



15
16
17
# File 'lib/terrafying/components/security/pagerduty_topic.rb', line 15

def self.create(*args)
  PagerdutyTopic.new.create(*args)
end

Instance Method Details

#create(name, escalation_policy_id:) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/terrafying/components/security/pagerduty_topic.rb', line 19

def create(
      name,
      escalation_policy_id:
    )

  ident = tf_safe(name)

  service = resource :pagerduty_service, ident, {
                       name: name,
                       auto_resolve_timeout: 14400,
                       acknowledgement_timeout: 600,
                       escalation_policy: escalation_policy_id,
                     }

  vendor = data :pagerduty_vendor, ident, {
                  name: "Amazon CloudWatch",
                }

  integration = resource :pagerduty_service_integration, ident, {
                           name: "SNS",
                           vendor: vendor["id"],
                           service: service["id"],
                         }

  topic = resource :aws_sns_topic, ident, {}

  @arn = topic["arn"]

  resource :aws_sns_topic_subscription, ident, {
             topic_arn: @arn,
             protocol: "https",
             endpoint: "https://events.pagerduty.com/integration/#{integration["integration_key"]}/enqueue",
             endpoint_auto_confirms: true,
           }

  self
end