terraforming 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +12 -0
- data/README.md +2 -0
- data/lib/terraforming.rb +2 -0
- data/lib/terraforming/cli.rb +11 -1
- data/lib/terraforming/resource/route53_record.rb +1 -1
- data/lib/terraforming/resource/sns_topic.rb +75 -0
- data/lib/terraforming/resource/sns_topic_subscription.rb +83 -0
- data/lib/terraforming/template/tf/network_acl.erb +8 -0
- data/lib/terraforming/template/tf/sns_topic.erb +17 -0
- data/lib/terraforming/template/tf/sns_topic_subscription.erb +23 -0
- data/lib/terraforming/version.rb +1 -1
- data/terraforming.gemspec +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c5cba83f78c4e252cd0fe5bea73a238a9e8f651
|
4
|
+
data.tar.gz: a2c3b770b7986822234f8f91914b1acb92097565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 844e51ae9255465e773915b266f281adb71920e9a18de7d6788aeebf51d7d1609f9fd96bf2fcaa47f5f38924da28f49d35ab37e3c5a6cf4c17b940a6a73d4698
|
7
|
+
data.tar.gz: b7eb1e7832659e0f3476d00a5b90673c782101880beb0abc617991865f5f0e18e7ba948b3e00c7a7ba45f447e5edc4b0d27f09abb2d99c11135cde5305a018bb
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# [v0.14.0](https://github.com/dtan4/terraforming/releases/tag/v0.14.0) (2017-08-05)
|
2
|
+
|
3
|
+
## Fixed / Updated
|
4
|
+
|
5
|
+
- Drop Ruby 2.1 from CI [#351](https://github.com/dtan4/terraforming/pull/351)
|
6
|
+
- Add `icmp_code` and `icmp_type` to NACL [#350](https://github.com/dtan4/terraforming/pull/350)
|
7
|
+
- Use aws-sdk [#349](https://github.com/dtan4/terraforming/pull/349)
|
8
|
+
- Rename title of aws_route53_record with wildcard [#348](https://github.com/dtan4/terraforming/pull/348) (thanks @furhouse)
|
9
|
+
- SNS Support [#332](https://github.com/dtan4/terraforming/pull/332) (thanks @uberblah)
|
10
|
+
- `terraforming snst` (SNS Topic), `terraforming snss` (SNS Subscription)
|
11
|
+
- Fix typo in cli.rb [#329](https://github.com/dtan4/terraforming/pull/329) (thanks @slalFe)
|
12
|
+
|
1
13
|
# [v0.13.2](https://github.com/dtan4/terraforming/releases/tag/v0.13.2) (2017-04-20)
|
2
14
|
|
3
15
|
## Fixed / Updated
|
data/README.md
CHANGED
@@ -115,6 +115,8 @@ Commands:
|
|
115
115
|
terraforming s3 # S3
|
116
116
|
terraforming sg # Security Group
|
117
117
|
terraforming sn # Subnet
|
118
|
+
terraforming snst # SNS Topic
|
119
|
+
terraforming snss # SNS Subscription
|
118
120
|
terraforming sqs # SQS
|
119
121
|
terraforming vgw # VPN Gateway
|
120
122
|
terraforming vpc # VPC
|
data/lib/terraforming.rb
CHANGED
data/lib/terraforming/cli.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Terraforming
|
2
2
|
class CLI < Thor
|
3
3
|
class_option :merge, type: :string, desc: "tfstate file to merge"
|
4
|
-
class_option :overwrite, type: :boolean, desc: "Overwrite
|
4
|
+
class_option :overwrite, type: :boolean, desc: "Overwrite existing tfstate"
|
5
5
|
class_option :tfstate, type: :boolean, desc: "Generate tfstate"
|
6
6
|
class_option :profile, type: :string, desc: "AWS credentials profile"
|
7
7
|
class_option :region, type: :string, desc: "AWS region"
|
@@ -214,6 +214,16 @@ module Terraforming
|
|
214
214
|
execute(Terraforming::Resource::VPNGateway, options)
|
215
215
|
end
|
216
216
|
|
217
|
+
desc "snst", "SNS Topic"
|
218
|
+
def snst
|
219
|
+
execute(Terraforming::Resource::SNSTopic, options)
|
220
|
+
end
|
221
|
+
|
222
|
+
desc "snss", "SNS Subscription"
|
223
|
+
def snss
|
224
|
+
execute(Terraforming::Resource::SNSTopicSubscription, options)
|
225
|
+
end
|
226
|
+
|
217
227
|
private
|
218
228
|
|
219
229
|
def configure_aws(options)
|
@@ -95,7 +95,7 @@ module Terraforming
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def module_name_of(record, counter)
|
98
|
-
normalize_module_name(name_of(record.name) + "-" + record.type + (!counter.nil? ? "-" + counter.to_s : ""))
|
98
|
+
normalize_module_name(name_of(record.name.gsub(/\\052/, 'wildcard')) + "-" + record.type + (!counter.nil? ? "-" + counter.to_s : ""))
|
99
99
|
end
|
100
100
|
|
101
101
|
def zone_id_of(hosted_zone)
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class SNSTopic
|
4
|
+
include Terraforming::Util
|
5
|
+
|
6
|
+
def self.tf(client: Aws::SNS::Client.new)
|
7
|
+
self.new(client).tf
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.tfstate(client: Aws::SNS::Client.new)
|
11
|
+
self.new(client).tfstate
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(client)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
18
|
+
def tf
|
19
|
+
apply_template(@client, "tf/sns_topic")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
topics.inject({}) do |resources, topic|
|
24
|
+
attributes = {
|
25
|
+
"name" => module_name_of(topic),
|
26
|
+
"id" => topic["TopicArn"],
|
27
|
+
"arn" => topic["TopicArn"],
|
28
|
+
"display_name" => topic["DisplayName"],
|
29
|
+
"policy" => topic.key?("Policy") ? topic["Policy"] : "",
|
30
|
+
"delivery_policy" => topic.key?("DeliveryPolicy") ? topic["DeliveryPolicy"] : ""
|
31
|
+
}
|
32
|
+
resources["aws_sns_topic.#{module_name_of(topic)}"] = {
|
33
|
+
"type" => "aws_sns_topic",
|
34
|
+
"primary" => {
|
35
|
+
"id" => topic["TopicArn"],
|
36
|
+
"attributes" => attributes
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
resources
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def topics
|
47
|
+
topic_arns.map do |topic_arn|
|
48
|
+
attributes = @client.get_topic_attributes({
|
49
|
+
topic_arn: topic_arn,
|
50
|
+
}).attributes
|
51
|
+
attributes["TopicArn"] = topic_arn
|
52
|
+
attributes
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def topic_arns
|
57
|
+
token = ""
|
58
|
+
arns = []
|
59
|
+
|
60
|
+
loop do
|
61
|
+
resp = @client.list_topics(next_token: token)
|
62
|
+
arns += resp.topics.map(&:topic_arn).flatten
|
63
|
+
token = resp.next_token
|
64
|
+
break if token.nil?
|
65
|
+
end
|
66
|
+
|
67
|
+
arns
|
68
|
+
end
|
69
|
+
|
70
|
+
def module_name_of(topic)
|
71
|
+
normalize_module_name(topic["TopicArn"].split(":").last)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class SNSTopicSubscription
|
4
|
+
include Terraforming::Util
|
5
|
+
|
6
|
+
def self.tf(client: Aws::SNS::Client.new)
|
7
|
+
self.new(client).tf
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.tfstate(client: Aws::SNS::Client.new)
|
11
|
+
self.new(client).tfstate
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(client)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
18
|
+
def tf
|
19
|
+
apply_template(@client, "tf/sns_topic_subscription")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
subscriptions.reject { |x| x["Protocol"].include?("email") }
|
24
|
+
.inject({}) do |resources, subscription|
|
25
|
+
attributes = {
|
26
|
+
"id" => subscription["SubscriptionArn"],
|
27
|
+
"topic_arn" => subscription["TopicArn"],
|
28
|
+
"protocol" => subscription["Protocol"],
|
29
|
+
"endpoint" => subscription["Endpoint"],
|
30
|
+
"raw_message_delivery" =>
|
31
|
+
subscription.key?("RawMessageDelivery") ? subscription["RawMessageDelivery"] : "false",
|
32
|
+
"confirmation_timeout_in_minutes" =>
|
33
|
+
subscription.key?("ConfirmationTimeoutInMinutes") ? subscription["ConfirmationTimeoutInMinutes"] : "1",
|
34
|
+
"endpoint_auto_confirms" =>
|
35
|
+
subscription.key?("EndpointAutoConfirms") ? subscription["EndpointAutoConfirms"] : "false"
|
36
|
+
}
|
37
|
+
resources["aws_sns_topic_subscription.#{module_name_of(subscription)}"] = {
|
38
|
+
"type" => "aws_sns_topic_subscription",
|
39
|
+
"primary" => {
|
40
|
+
"id" => subscription["SubscriptionArn"],
|
41
|
+
"attributes" => attributes
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
resources
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def subscriptions
|
52
|
+
subscription_arns.map do |subscription_arn|
|
53
|
+
# check explicitly for an issue with some subscriptions that returns ARN=PendingConfirmation
|
54
|
+
next if subscription_arn == "PendingConfirmation"
|
55
|
+
|
56
|
+
attributes = @client.get_subscription_attributes({
|
57
|
+
subscription_arn: subscription_arn,
|
58
|
+
}).attributes
|
59
|
+
attributes["SubscriptionArn"] = subscription_arn
|
60
|
+
attributes
|
61
|
+
end.compact
|
62
|
+
end
|
63
|
+
|
64
|
+
def subscription_arns
|
65
|
+
token = ""
|
66
|
+
arns = []
|
67
|
+
|
68
|
+
loop do
|
69
|
+
resp = @client.list_subscriptions(next_token: token)
|
70
|
+
arns += resp.subscriptions.map(&:subscription_arn).flatten
|
71
|
+
token = resp.next_token
|
72
|
+
break if token.nil?
|
73
|
+
end
|
74
|
+
|
75
|
+
arns
|
76
|
+
end
|
77
|
+
|
78
|
+
def module_name_of(subscription)
|
79
|
+
normalize_module_name(subscription["SubscriptionArn"].split(":").last)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -11,6 +11,10 @@ resource "aws_network_acl" "<%= module_name_of(network_acl) %>" {
|
|
11
11
|
action = "<%= ingress.rule_action %>"
|
12
12
|
protocol = "<%= ingress.protocol %>"
|
13
13
|
cidr_block = "<%= ingress.cidr_block %>"
|
14
|
+
<%- if ingress.icmp_type_code -%>
|
15
|
+
icmp_code = "<%= ingress.icmp_type_code.code %>"
|
16
|
+
icmp_type = "<%= ingress.icmp_type_code.type %>"
|
17
|
+
<%- end -%>
|
14
18
|
}
|
15
19
|
|
16
20
|
<% end -%>
|
@@ -22,6 +26,10 @@ resource "aws_network_acl" "<%= module_name_of(network_acl) %>" {
|
|
22
26
|
action = "<%= egress.rule_action %>"
|
23
27
|
protocol = "<%= egress.protocol %>"
|
24
28
|
cidr_block = "<%= egress.cidr_block %>"
|
29
|
+
<%- if egress.icmp_type_code -%>
|
30
|
+
icmp_code = "<%= egress.icmp_type_code.code %>"
|
31
|
+
icmp_type = "<%= egress.icmp_type_code.type %>"
|
32
|
+
<%- end -%>
|
25
33
|
}
|
26
34
|
|
27
35
|
<% end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% topics.each do |topic| -%>
|
2
|
+
resource "aws_sns_topic" "<%= module_name_of(topic) %>" {
|
3
|
+
name = "<%= module_name_of(topic) %>"
|
4
|
+
display_name = "<%= topic["DisplayName"] %>"
|
5
|
+
<% if topic.key? "Policy" -%>
|
6
|
+
policy = <<POLICY
|
7
|
+
<%= prettify_policy(topic["Policy"], unescape: true) %>
|
8
|
+
POLICY
|
9
|
+
<% end -%>
|
10
|
+
<% if topic.key? "DeliveryPolicy" -%>
|
11
|
+
delivery_policy = <<POLICY
|
12
|
+
<%= prettify_policy(topic["DeliveryPolicy"], unescape: true) %>
|
13
|
+
POLICY
|
14
|
+
<% end -%>
|
15
|
+
}
|
16
|
+
|
17
|
+
<% end -%>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% subscriptions.each do |subscription| -%>
|
2
|
+
<% if subscription["Protocol"].include?("email") -%>
|
3
|
+
/*
|
4
|
+
<% end -%>
|
5
|
+
resource "aws_sns_topic_subscription" "<%= module_name_of(subscription) %>" {
|
6
|
+
topic_arn = "<%= subscription["TopicArn"] %>"
|
7
|
+
protocol = "<%= subscription["Protocol"] %>"
|
8
|
+
endpoint = "<%= subscription["Endpoint"] %>"
|
9
|
+
<% if subscription.key? "RawMessageDelivery" -%>
|
10
|
+
raw_message_delivery = "<%= subscription["RawMessageDelivery"] %>"
|
11
|
+
<% end -%>
|
12
|
+
<% if subscription.key? "ConfirmationTimeoutInMinutes" %>
|
13
|
+
confirmation_timeout_in_minutes = "<%= subscription["ConfirmationTimeoutInMinutes"] %>"
|
14
|
+
<% end -%>
|
15
|
+
<% if subscription.key? "EndpointAutoConfirms" %>
|
16
|
+
endpoint_auto_confirms = "<%= subscription["EndpointAutoConfirms"] %>"
|
17
|
+
<% end -%>
|
18
|
+
}
|
19
|
+
<% if subscription["Protocol"].include?("email") -%>
|
20
|
+
*/
|
21
|
+
<% end -%>
|
22
|
+
|
23
|
+
<% end -%>
|
data/lib/terraforming/version.rb
CHANGED
data/terraforming.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "aws-sdk", "~> 2.
|
22
|
+
spec.add_dependency "aws-sdk", "~> 2.10.17"
|
23
23
|
spec.add_dependency "multi_json", "~> 1.12.1"
|
24
24
|
spec.add_dependency "thor"
|
25
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraforming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daisuke Fujita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.10.17
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.10.17
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: multi_json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,6 +183,8 @@ files:
|
|
183
183
|
- lib/terraforming/resource/route_table_association.rb
|
184
184
|
- lib/terraforming/resource/s3.rb
|
185
185
|
- lib/terraforming/resource/security_group.rb
|
186
|
+
- lib/terraforming/resource/sns_topic.rb
|
187
|
+
- lib/terraforming/resource/sns_topic_subscription.rb
|
186
188
|
- lib/terraforming/resource/sqs.rb
|
187
189
|
- lib/terraforming/resource/subnet.rb
|
188
190
|
- lib/terraforming/resource/vpc.rb
|
@@ -224,6 +226,8 @@ files:
|
|
224
226
|
- lib/terraforming/template/tf/route_table_association.erb
|
225
227
|
- lib/terraforming/template/tf/s3.erb
|
226
228
|
- lib/terraforming/template/tf/security_group.erb
|
229
|
+
- lib/terraforming/template/tf/sns_topic.erb
|
230
|
+
- lib/terraforming/template/tf/sns_topic_subscription.erb
|
227
231
|
- lib/terraforming/template/tf/sqs.erb
|
228
232
|
- lib/terraforming/template/tf/subnet.erb
|
229
233
|
- lib/terraforming/template/tf/vpc.erb
|