Commit 4ea01fa0 authored by Daisuke Fujita's avatar Daisuke Fujita

Generate Network ACL tfstate

parent 2263033d
......@@ -19,20 +19,17 @@ module Terraforming::Resource
end
def tfstate
resources = security_groups.inject({}) do |result, security_group|
resources = network_acls.inject({}) do |result, network_acl|
attributes = {
"description" => security_group.description,
"egress.#" => security_group.ip_permissions_egress.length.to_s,
"id" => security_group.group_id,
"ingress.#" => security_group.ip_permissions.length.to_s,
"name" => security_group.group_name,
"owner_id" => security_group.owner_id,
"vpc_id" => security_group.vpc_id || "",
"egress.#" => egresses_of(network_acl).length.to_s,
"id" => network_acl.network_acl_id,
"ingress.#" => ingresses_of(network_acl).length.to_s,
"vpc_id" => network_acl.vpc_id,
}
result["aws_security_group.#{module_name_of(security_group)}"] = {
"type" => "aws_security_group",
result["aws_network_acl.#{module_name_of(network_acl)}"] = {
"type" => "aws_network_acl",
"primary" => {
"id" => security_group.group_id,
"id" => network_acl.network_acl_id,
"attributes" => attributes
}
}
......
......@@ -46,10 +46,7 @@ module Terraforming::Resource
},
],
tags: [
{
key: "Name",
value: "hoge"
},
{ key: "Name", value: "hoge" },
]
},
{
......@@ -90,10 +87,7 @@ module Terraforming::Resource
},
],
tags: [
{
key: "Name",
value: "fuga"
},
{ key: "Name", value: "fuga" },
]
},
]
......@@ -155,7 +149,7 @@ resource "aws_network_acl" "fuga" {
end
describe ".tfstate" do
xit "should generate tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
......@@ -165,33 +159,27 @@ resource "aws_network_acl" "fuga" {
],
"outputs" => {},
"resources" => {
"aws_security_group.hoge" => {
"type" => "aws_security_group",
"aws_network_acl.hoge" => {
"type" => "aws_network_acl",
"primary" => {
"id" => "sg-1234abcd",
"id" => "acl-1234abcd",
"attributes" => {
"description" => "Group for hoge",
"egress.#" => "1",
"id" => "sg-1234abcd",
"id" => "acl-1234abcd",
"ingress.#" => "1",
"name" => "hoge",
"owner_id" => "012345678901",
"vpc_id" => "",
"vpc_id" => "vpc-1234abcd",
}
}
},
"aws_security_group.fuga" => {
"type" => "aws_security_group",
"aws_network_acl.fuga" => {
"type" => "aws_network_acl",
"primary" => {
"id" => "sg-5678efgh",
"id" => "acl-5678efgh",
"attributes" => {
"description" => "Group for fuga",
"egress.#" => "0",
"id" => "sg-5678efgh",
"ingress.#" => "2",
"name" => "fuga",
"owner_id" => "098765432109",
"vpc_id" => "vpc-1234abcd",
"egress.#" => "1",
"id" => "acl-5678efgh",
"ingress.#" => "1",
"vpc_id" => "vpc-5678efgh",
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment