terraforming 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/terraforming/resource/iam_group_policy.rb +1 -1
- data/lib/terraforming/resource/iam_policy.rb +1 -1
- data/lib/terraforming/resource/iam_role.rb +2 -1
- data/lib/terraforming/resource/iam_role_policy.rb +1 -1
- data/lib/terraforming/resource/iam_user_policy.rb +1 -1
- data/lib/terraforming/resource/s3.rb +10 -1
- data/lib/terraforming/template/tf/iam_group_policy.erb +1 -1
- data/lib/terraforming/template/tf/iam_policy.erb +1 -1
- data/lib/terraforming/template/tf/iam_role.erb +1 -1
- data/lib/terraforming/template/tf/iam_role_policy.erb +1 -1
- data/lib/terraforming/template/tf/iam_user_policy.erb +1 -1
- data/lib/terraforming/template/tf/s3.erb +5 -0
- data/lib/terraforming/util.rb +2 -2
- data/lib/terraforming/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 456f41b8b7dace703db8fe006d3ba82789353a1a
|
4
|
+
data.tar.gz: deab4d92676649424ffbab582995085c098ac9de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d21bab80223eac19400fcca1c389a7b8cba2862a942afe4fe230c35e03c715c70be9733d8ab44bed849ab582c5df1bcbf5d617d95b31fe80b08539730ca85aa
|
7
|
+
data.tar.gz: 5d3347dcf189fb4468e147f722894ac664946fd915240a5f7af8e9b73675665889f0135f85e09293230633d954c23b7ce1223ff8da1b449cb77caa9fffef2b4b
|
data/CHANGELOG.md
CHANGED
@@ -25,7 +25,7 @@ module Terraforming
|
|
25
25
|
"group" => policy.group_name,
|
26
26
|
"id" => iam_group_policy_id_of(policy),
|
27
27
|
"name" => policy.policy_name,
|
28
|
-
"policy" => prettify_policy(policy.policy_document, true)
|
28
|
+
"policy" => prettify_policy(policy.policy_document, breakline: true, unescape: true)
|
29
29
|
}
|
30
30
|
resources["aws_iam_group_policy.#{policy.policy_name}"] = {
|
31
31
|
"type" => "aws_iam_group_policy",
|
@@ -26,7 +26,7 @@ module Terraforming
|
|
26
26
|
"id" => policy.arn,
|
27
27
|
"name" => policy.policy_name,
|
28
28
|
"path" => policy.path,
|
29
|
-
"policy" => prettify_policy(version.document, true),
|
29
|
+
"policy" => prettify_policy(version.document, breakline: true, unescape: true),
|
30
30
|
}
|
31
31
|
resources["aws_iam_policy.#{policy.policy_name}"] = {
|
32
32
|
"type" => "aws_iam_policy",
|
@@ -23,7 +23,8 @@ module Terraforming
|
|
23
23
|
iam_roles.inject({}) do |resources, role|
|
24
24
|
attributes = {
|
25
25
|
"arn" => role.arn,
|
26
|
-
"assume_role_policy" =>
|
26
|
+
"assume_role_policy" =>
|
27
|
+
prettify_policy(role.assume_role_policy_document, breakline: true, unescape: true),
|
27
28
|
"id" => role.role_name,
|
28
29
|
"name" => role.role_name,
|
29
30
|
"path" => role.path,
|
@@ -24,7 +24,7 @@ module Terraforming
|
|
24
24
|
attributes = {
|
25
25
|
"id" => iam_role_policy_id_of(policy),
|
26
26
|
"name" => policy.policy_name,
|
27
|
-
"policy" => prettify_policy(policy.policy_document, true),
|
27
|
+
"policy" => prettify_policy(policy.policy_document, breakline: true, unescape: true),
|
28
28
|
"role" => policy.role_name,
|
29
29
|
}
|
30
30
|
resources["aws_iam_role_policy.#{policy.policy_name}"] = {
|
@@ -24,7 +24,7 @@ module Terraforming
|
|
24
24
|
attributes = {
|
25
25
|
"id" => iam_user_policy_id_of(policy),
|
26
26
|
"name" => policy.policy_name,
|
27
|
-
"policy" => prettify_policy(policy.policy_document, true),
|
27
|
+
"policy" => prettify_policy(policy.policy_document, breakline: true, unescape: true),
|
28
28
|
"user" => policy.user_name,
|
29
29
|
}
|
30
30
|
resources["aws_iam_user_policy.#{policy.policy_name}"] = {
|
@@ -21,6 +21,7 @@ module Terraforming
|
|
21
21
|
|
22
22
|
def tfstate
|
23
23
|
buckets.inject({}) do |resources, bucket|
|
24
|
+
bucket_policy = bucket_policy_of(bucket)
|
24
25
|
resources["aws_s3_bucket.#{module_name_of(bucket)}"] = {
|
25
26
|
"type" => "aws_s3_bucket",
|
26
27
|
"primary" => {
|
@@ -28,7 +29,9 @@ module Terraforming
|
|
28
29
|
"attributes" => {
|
29
30
|
"acl" => "private",
|
30
31
|
"bucket" => bucket.name,
|
31
|
-
"
|
32
|
+
"force_destroy" => "false",
|
33
|
+
"id" => bucket.name,
|
34
|
+
"policy" => bucket_policy ? bucket_policy.policy.read : "",
|
32
35
|
}
|
33
36
|
}
|
34
37
|
}
|
@@ -39,6 +42,12 @@ module Terraforming
|
|
39
42
|
|
40
43
|
private
|
41
44
|
|
45
|
+
def bucket_policy_of(bucket)
|
46
|
+
@client.get_bucket_policy(bucket: bucket.name)
|
47
|
+
rescue Aws::S3::Errors::NoSuchBucketPolicy
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
42
51
|
def buckets
|
43
52
|
@client.list_buckets.buckets
|
44
53
|
end
|
@@ -3,7 +3,7 @@ resource "aws_iam_group_policy" "<%= policy.policy_name %>" {
|
|
3
3
|
name = "<%= policy.policy_name %>"
|
4
4
|
group = "<%= policy.group_name %>"
|
5
5
|
policy = <<POLICY
|
6
|
-
<%= prettify_policy(policy.policy_document) %>
|
6
|
+
<%= prettify_policy(policy.policy_document, unescape: true) %>
|
7
7
|
POLICY
|
8
8
|
}
|
9
9
|
|
@@ -3,7 +3,7 @@ resource "aws_iam_role" "<%= role.role_name %>" {
|
|
3
3
|
name = "<%= role.role_name %>"
|
4
4
|
path = "<%= role.path %>"
|
5
5
|
assume_role_policy = <<POLICY
|
6
|
-
<%= prettify_policy(role.assume_role_policy_document) %>
|
6
|
+
<%= prettify_policy(role.assume_role_policy_document, unescape: true) %>
|
7
7
|
POLICY
|
8
8
|
}
|
9
9
|
|
@@ -3,7 +3,7 @@ resource "aws_iam_role_policy" "<%= policy.policy_name %>" {
|
|
3
3
|
name = "<%= policy.policy_name %>"
|
4
4
|
role = "<%= policy.role_name %>"
|
5
5
|
policy = <<POLICY
|
6
|
-
<%= prettify_policy(policy.policy_document) %>
|
6
|
+
<%= prettify_policy(policy.policy_document, unescape: true) %>
|
7
7
|
POLICY
|
8
8
|
}
|
9
9
|
|
@@ -3,7 +3,7 @@ resource "aws_iam_user_policy" "<%= policy.policy_name %>" {
|
|
3
3
|
name = "<%= policy.policy_name %>"
|
4
4
|
user = "<%= policy.user_name %>"
|
5
5
|
policy = <<POLICY
|
6
|
-
<%= prettify_policy(policy.policy_document) %>
|
6
|
+
<%= prettify_policy(policy.policy_document, unescape: true) %>
|
7
7
|
POLICY
|
8
8
|
}
|
9
9
|
|
@@ -2,6 +2,11 @@
|
|
2
2
|
resource "aws_s3_bucket" "<%= module_name_of(bucket) %>" {
|
3
3
|
bucket = "<%= bucket.name %>"
|
4
4
|
acl = "private"
|
5
|
+
<%- unless (policy = bucket_policy_of(bucket)).nil? -%>
|
6
|
+
policy = <<POLICY
|
7
|
+
<%= prettify_policy(policy.policy.read) %>
|
8
|
+
POLICY
|
9
|
+
<%- end -%>
|
5
10
|
}
|
6
11
|
|
7
12
|
<% end -%>
|
data/lib/terraforming/util.rb
CHANGED
@@ -17,8 +17,8 @@ module Terraforming
|
|
17
17
|
File.join(File.expand_path(File.dirname(__FILE__)), "template", template_name) << ".erb"
|
18
18
|
end
|
19
19
|
|
20
|
-
def prettify_policy(
|
21
|
-
json = JSON.pretty_generate(JSON.parse(CGI.unescape(
|
20
|
+
def prettify_policy(document, breakline: false, unescape: false)
|
21
|
+
json = JSON.pretty_generate(JSON.parse(unescape ? CGI.unescape(document) : document))
|
22
22
|
|
23
23
|
if breakline
|
24
24
|
json[-1] != "\n" ? json << "\n" : json
|
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daisuke Fujita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -258,9 +258,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
258
|
version: '0'
|
259
259
|
requirements: []
|
260
260
|
rubyforge_project:
|
261
|
-
rubygems_version: 2.4.
|
261
|
+
rubygems_version: 2.4.5
|
262
262
|
signing_key:
|
263
263
|
specification_version: 4
|
264
264
|
summary: Export existing AWS resources to Terraform style (tf, tfstate)
|
265
265
|
test_files: []
|
266
|
-
has_rdoc:
|