terraforming 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +9 -0
- data/lib/terraforming.rb +1 -0
- data/lib/terraforming/cli.rb +5 -0
- data/lib/terraforming/resource/elb.rb +27 -0
- data/lib/terraforming/resource/iam_policy_attachment.rb +69 -0
- data/lib/terraforming/template/tf/elb.erb +9 -0
- data/lib/terraforming/template/tf/iam_policy_attachment.erb +10 -0
- data/lib/terraforming/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e25c86438b0694ab932b97b00822656e83141f71
|
4
|
+
data.tar.gz: 861aa06a491303fa7cdf1c58a6d85af7190e232d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71bdf8cf49d0a7ba4920c2c798671a81e72c572aae3226ac25d4f93596a14e9b1919f63607f79e0f7595b8bbb2f5111dd61a4d67c7443d891e72e5de151180f9
|
7
|
+
data.tar.gz: 323795cc9c10264244424123ed34df95e11b3a75384d0067588a8aa759c20c2a77c14aed9572e989ac49dce7701500cf39b15b99aac7d3ef46f44e5a246b744b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# [v0.9.0](https://github.com/dtan4/terraforming/releases/tag/v0.8.0) (2016-06-12)
|
2
|
+
|
3
|
+
## Resource
|
4
|
+
|
5
|
+
- AWS IAM Policy Attachment #225
|
6
|
+
|
7
|
+
## Fixed / Updated
|
8
|
+
|
9
|
+
- Add `access_logs` attribute to ELB #223
|
10
|
+
- Add `internal` attribute to ELB #221 (thanks @kbruner)
|
11
|
+
|
1
12
|
# [v0.8.0](https://github.com/dtan4/terraforming/releases/tag/v0.8.0) (2016-05-29)
|
2
13
|
|
3
14
|
## Notice
|
data/README.md
CHANGED
@@ -79,11 +79,13 @@ Commands:
|
|
79
79
|
terraforming ecsn # ElastiCache Subnet Group
|
80
80
|
terraforming eip # EIP
|
81
81
|
terraforming elb # ELB
|
82
|
+
terraforming help [COMMAND] # Describe available commands or one specifi...
|
82
83
|
terraforming iamg # IAM Group
|
83
84
|
terraforming iamgm # IAM Group Membership
|
84
85
|
terraforming iamgp # IAM Group Policy
|
85
86
|
terraforming iamip # IAM Instance Profile
|
86
87
|
terraforming iamp # IAM Policy
|
88
|
+
terraforming iamp # IAM Policy Attachment
|
87
89
|
terraforming iamr # IAM Role
|
88
90
|
terraforming iamrp # IAM Role Policy
|
89
91
|
terraforming iamu # IAM User
|
@@ -104,6 +106,13 @@ Commands:
|
|
104
106
|
terraforming sqs # SQS
|
105
107
|
terraforming vgw # VPN Gateway
|
106
108
|
terraforming vpc # VPC
|
109
|
+
|
110
|
+
Options:
|
111
|
+
[--merge=MERGE] # tfstate file to merge
|
112
|
+
[--overwrite], [--no-overwrite] # Overwrite existng tfstate
|
113
|
+
[--tfstate], [--no-tfstate] # Generate tfstate
|
114
|
+
[--profile=PROFILE] # AWS credentials profile
|
115
|
+
[--region=REGION] # AWS region
|
107
116
|
```
|
108
117
|
|
109
118
|
### Export tf
|
data/lib/terraforming.rb
CHANGED
@@ -25,6 +25,7 @@ require "terraforming/resource/iam_group_membership"
|
|
25
25
|
require "terraforming/resource/iam_group_policy"
|
26
26
|
require "terraforming/resource/iam_instance_profile"
|
27
27
|
require "terraforming/resource/iam_policy"
|
28
|
+
require "terraforming/resource/iam_policy_attachment"
|
28
29
|
require "terraforming/resource/iam_role"
|
29
30
|
require "terraforming/resource/iam_role_policy"
|
30
31
|
require "terraforming/resource/iam_user"
|
data/lib/terraforming/cli.rb
CHANGED
@@ -76,6 +76,11 @@ module Terraforming
|
|
76
76
|
execute(Terraforming::Resource::IAMPolicy, options)
|
77
77
|
end
|
78
78
|
|
79
|
+
desc "iamp", "IAM Policy Attachment"
|
80
|
+
def iampa
|
81
|
+
execute(Terraforming::Resource::IAMPolicyAttachment, options)
|
82
|
+
end
|
83
|
+
|
79
84
|
desc "iamr", "IAM Role"
|
80
85
|
def iamr
|
81
86
|
execute(Terraforming::Resource::IAMRole, options)
|
@@ -31,10 +31,16 @@ module Terraforming
|
|
31
31
|
"id" => load_balancer.load_balancer_name,
|
32
32
|
"idle_timeout" => load_balancer_attributes.connection_settings.idle_timeout.to_s,
|
33
33
|
"instances.#" => load_balancer.instances.length.to_s,
|
34
|
+
"internal" => internal?(load_balancer).to_s,
|
34
35
|
"name" => load_balancer.load_balancer_name,
|
35
36
|
"source_security_group" => load_balancer.source_security_group.group_name,
|
36
37
|
}
|
37
38
|
|
39
|
+
if load_balancer_attributes.access_log.enabled
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
attributes.merge!(access_logs_attributes_of(load_balancer_attributes))
|
38
44
|
attributes.merge!(healthcheck_attributes_of(load_balancer))
|
39
45
|
attributes.merge!(listeners_attributes_of(load_balancer))
|
40
46
|
attributes.merge!(sg_attributes_of(load_balancer))
|
@@ -55,6 +61,23 @@ module Terraforming
|
|
55
61
|
end
|
56
62
|
end
|
57
63
|
|
64
|
+
def access_logs_attributes_of(load_balancer_attributes)
|
65
|
+
access_log = load_balancer_attributes.access_log
|
66
|
+
|
67
|
+
if access_log.enabled
|
68
|
+
{
|
69
|
+
"access_logs.#" => "1",
|
70
|
+
"access_logs.0.bucket" => access_log.s3_bucket_name,
|
71
|
+
"access_logs.0.bucket_prefix" => access_log.s3_bucket_prefix,
|
72
|
+
"access_logs.0.interval" => access_log.emit_interval.to_s,
|
73
|
+
}
|
74
|
+
else
|
75
|
+
{
|
76
|
+
"access_logs.#" => "0",
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
58
81
|
def healthcheck_attributes_of(elb)
|
59
82
|
hashcode = healthcheck_hashcode_of(elb.health_check)
|
60
83
|
attributes = {
|
@@ -172,6 +195,10 @@ module Terraforming
|
|
172
195
|
def vpc_elb?(load_balancer)
|
173
196
|
load_balancer.vpc_id != ""
|
174
197
|
end
|
198
|
+
|
199
|
+
def internal?(load_balancer)
|
200
|
+
load_balancer.scheme == "internal"
|
201
|
+
end
|
175
202
|
end
|
176
203
|
end
|
177
204
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class IAMPolicyAttachment
|
4
|
+
include Terraforming::Util
|
5
|
+
|
6
|
+
def self.tf(client: Aws::IAM::Client.new)
|
7
|
+
self.new(client).tf
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.tfstate(client: Aws::IAM::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/iam_policy_attachment")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
iam_policy_attachments.inject({}) do |resources, policy_attachment|
|
24
|
+
attributes = {
|
25
|
+
"id" => policy_attachment[:name],
|
26
|
+
"name" => policy_attachment[:name],
|
27
|
+
"policy_arn" => policy_attachment[:arn],
|
28
|
+
"groups.#" => policy_attachment[:entities].policy_groups.length.to_s,
|
29
|
+
"users.#" => policy_attachment[:entities].policy_users.length.to_s,
|
30
|
+
"roles.#" => policy_attachment[:entities].policy_roles.length.to_s,
|
31
|
+
}
|
32
|
+
resources["aws_iam_policy_attachment.#{policy_attachment[:name]}"] = {
|
33
|
+
"type" => "aws_iam_policy_attachment",
|
34
|
+
"primary" => {
|
35
|
+
"id" => policy_attachment[:name],
|
36
|
+
"attributes" => attributes
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
resources
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def attachment_name_from(policy)
|
47
|
+
"#{policy.policy_name}-policy-attachment"
|
48
|
+
end
|
49
|
+
|
50
|
+
def entities_for_policy(policy)
|
51
|
+
@client.list_entities_for_policy(policy_arn: policy.arn)
|
52
|
+
end
|
53
|
+
|
54
|
+
def iam_policies
|
55
|
+
@client.list_policies(scope: "Local").policies
|
56
|
+
end
|
57
|
+
|
58
|
+
def iam_policy_attachments
|
59
|
+
iam_policies.map do |policy|
|
60
|
+
{
|
61
|
+
arn: policy.arn,
|
62
|
+
entities: entities_for_policy(policy),
|
63
|
+
name: attachment_name_from(policy),
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -13,7 +13,16 @@ resource "aws_elb" "<%= module_name_of(load_balancer) %>" {
|
|
13
13
|
idle_timeout = <%= load_balancer_attributes.connection_settings.idle_timeout %>
|
14
14
|
connection_draining = <%= load_balancer_attributes.connection_draining.enabled %>
|
15
15
|
connection_draining_timeout = <%= load_balancer_attributes.connection_draining.timeout %>
|
16
|
+
internal = <%= internal?(load_balancer).to_s %>
|
16
17
|
|
18
|
+
<%- if load_balancer_attributes.access_log.enabled -%>
|
19
|
+
access_logs {
|
20
|
+
bucket = "<%= load_balancer_attributes.access_log.s3_bucket_name %>"
|
21
|
+
bucket_prefix = "<%= load_balancer_attributes.access_log.s3_bucket_prefix %>"
|
22
|
+
interval = <%= load_balancer_attributes.access_log.emit_interval %>
|
23
|
+
}
|
24
|
+
|
25
|
+
<%- end -%>
|
17
26
|
<% load_balancer.listener_descriptions.map { |ld| ld.listener }.map do |listener| -%>
|
18
27
|
listener {
|
19
28
|
instance_port = <%= listener.instance_port %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% iam_policy_attachments.each do |policy_attachment| -%>
|
2
|
+
resource "aws_iam_policy_attachment" "<%= policy_attachment[:name] %>" {
|
3
|
+
name = "<%= policy_attachment[:name] %>"
|
4
|
+
policy_arn = "<%= policy_attachment[:arn] %>"
|
5
|
+
groups = <%= policy_attachment[:entities].policy_groups.map(&:group_name).inspect %>
|
6
|
+
users = <%= policy_attachment[:entities].policy_users.map(&:user_name).inspect %>
|
7
|
+
roles = <%= policy_attachment[:entities].policy_roles.map(&:role_name).inspect %>
|
8
|
+
}
|
9
|
+
|
10
|
+
<% end -%>
|
data/lib/terraforming/version.rb
CHANGED
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.9.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: 2016-
|
11
|
+
date: 2016-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/terraforming/resource/iam_group_policy.rb
|
173
173
|
- lib/terraforming/resource/iam_instance_profile.rb
|
174
174
|
- lib/terraforming/resource/iam_policy.rb
|
175
|
+
- lib/terraforming/resource/iam_policy_attachment.rb
|
175
176
|
- lib/terraforming/resource/iam_role.rb
|
176
177
|
- lib/terraforming/resource/iam_role_policy.rb
|
177
178
|
- lib/terraforming/resource/iam_user.rb
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- lib/terraforming/template/tf/iam_group_policy.erb
|
207
208
|
- lib/terraforming/template/tf/iam_instance_profile.erb
|
208
209
|
- lib/terraforming/template/tf/iam_policy.erb
|
210
|
+
- lib/terraforming/template/tf/iam_policy_attachment.erb
|
209
211
|
- lib/terraforming/template/tf/iam_role.erb
|
210
212
|
- lib/terraforming/template/tf/iam_role_policy.erb
|
211
213
|
- lib/terraforming/template/tf/iam_user.erb
|