Class: Terraforming::Resource::SNSTopic
- Inherits:
-
Object
- Object
- Terraforming::Resource::SNSTopic
show all
- Includes:
- Util
- Defined in:
- lib/terraforming/resource/sns_topic.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Util
#apply_template, #name_from_tag, #normalize_module_name, #prettify_policy, #template_path
Constructor Details
#initialize(client) ⇒ SNSTopic
Returns a new instance of SNSTopic.
14
15
16
|
# File 'lib/terraforming/resource/sns_topic.rb', line 14
def initialize(client)
@client = client
end
|
Class Method Details
.tf(client: Aws::SNS::Client.new) ⇒ Object
6
7
8
|
# File 'lib/terraforming/resource/sns_topic.rb', line 6
def self.tf(client: Aws::SNS::Client.new)
self.new(client).tf
end
|
.tfstate(client: Aws::SNS::Client.new) ⇒ Object
10
11
12
|
# File 'lib/terraforming/resource/sns_topic.rb', line 10
def self.tfstate(client: Aws::SNS::Client.new)
self.new(client).tfstate
end
|
Instance Method Details
#tf ⇒ Object
18
19
20
|
# File 'lib/terraforming/resource/sns_topic.rb', line 18
def tf
apply_template(@client, "tf/sns_topic")
end
|
#tfstate ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/terraforming/resource/sns_topic.rb', line 22
def tfstate
topics.inject({}) do |resources, topic|
attributes = {
"name" => module_name_of(topic),
"id" => topic["TopicArn"],
"arn" => topic["TopicArn"],
"display_name" => topic["DisplayName"],
"policy" => topic.key?("Policy") ? topic["Policy"] : "",
"delivery_policy" => topic.key?("DeliveryPolicy") ? topic["DeliveryPolicy"] : ""
}
resources["aws_sns_topic.#{module_name_of(topic)}"] = {
"type" => "aws_sns_topic",
"primary" => {
"id" => topic["TopicArn"],
"attributes" => attributes
}
}
resources
end
end
|