Commit 7456f869 authored by Daisuke Fujita's avatar Daisuke Fujita

Merge pull request #56 from endemics/modules-list-hash

Modules list hash
parents 1cc8e7a0 676f0a7e
......@@ -21,13 +21,15 @@ module Terraforming
tfstate = {
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => resources
}
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => resources
}
]
}
JSON.pretty_generate(tfstate)
......
......@@ -134,40 +134,42 @@ resource "aws_db_parameter_group" "default-postgres9-4" {
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_parameter_group.default-mysql5-6" => {
"type" => "aws_db_parameter_group",
"primary" => {
"id" => "default.mysql5.6",
"attributes" => {
"description" => "Default parameter group for mysql5.6",
"family" => "mysql5.6",
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_parameter_group.default-mysql5-6" => {
"type" => "aws_db_parameter_group",
"primary" => {
"id" => "default.mysql5.6",
"name" => "default.mysql5.6",
"parameter.#" => "2",
"attributes" => {
"description" => "Default parameter group for mysql5.6",
"family" => "mysql5.6",
"id" => "default.mysql5.6",
"name" => "default.mysql5.6",
"parameter.#" => "2",
}
}
}
},
"aws_db_parameter_group.default-postgres9-4" => {
"type" => "aws_db_parameter_group",
"primary" => {
"id" => "default.postgres9.4",
"attributes" => {
"description" => "Default parameter group for postgres9.4",
"family" => "postgres9.4",
},
"aws_db_parameter_group.default-postgres9-4" => {
"type" => "aws_db_parameter_group",
"primary" => {
"id" => "default.postgres9.4",
"name" => "default.postgres9.4",
"parameter.#" => "2",
"attributes" => {
"description" => "Default parameter group for postgres9.4",
"family" => "postgres9.4",
"id" => "default.postgres9.4",
"name" => "default.postgres9.4",
"parameter.#" => "2",
}
}
}
}
}
}
]
})
end
end
......
......@@ -94,38 +94,40 @@ resource "aws_db_security_group" "sgfoobar" {
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_security_group.default" => {
"type" => "aws_db_security_group",
"primary" => {
"id" => "default",
"attributes" => {
"db_subnet_group_name" => "default",
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_security_group.default" => {
"type" => "aws_db_security_group",
"primary" => {
"id" => "default",
"ingress.#" => "1",
"name" => "default",
"attributes" => {
"db_subnet_group_name" => "default",
"id" => "default",
"ingress.#" => "1",
"name" => "default",
}
}
}
},
"aws_db_security_group.sgfoobar" => {
"type" => "aws_db_security_group",
"primary" => {
"id" => "sgfoobar",
"attributes" => {
"db_subnet_group_name" => "sgfoobar",
},
"aws_db_security_group.sgfoobar" => {
"type" => "aws_db_security_group",
"primary" => {
"id" => "sgfoobar",
"ingress.#" => "2",
"name" => "sgfoobar",
"attributes" => {
"db_subnet_group_name" => "sgfoobar",
"id" => "sgfoobar",
"ingress.#" => "2",
"name" => "sgfoobar",
}
}
}
}
}
}
]
})
end
end
......
......@@ -84,36 +84,38 @@ resource "aws_db_subnet_group" "fuga" {
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_subnet_group.hoge" => {
"type" => "aws_db_subnet_group",
"primary" => {
"id" => "hoge",
"attributes" => {
"description" => "DB subnet group hoge",
"name" => "hoge",
"subnet_ids.#" => "2",
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_db_subnet_group.hoge" => {
"type" => "aws_db_subnet_group",
"primary" => {
"id" => "hoge",
"attributes" => {
"description" => "DB subnet group hoge",
"name" => "hoge",
"subnet_ids.#" => "2",
}
}
}
},
"aws_db_subnet_group.fuga" => {
"type" => "aws_db_subnet_group",
"primary" => {
"id" => "fuga",
"attributes" => {
"description" => "DB subnet group fuga",
"name" => "fuga",
"subnet_ids.#" => "2",
},
"aws_db_subnet_group.fuga" => {
"type" => "aws_db_subnet_group",
"primary" => {
"id" => "fuga",
"attributes" => {
"description" => "DB subnet group fuga",
"name" => "fuga",
"subnet_ids.#" => "2",
}
}
}
}
}
}
]
})
end
end
......
......@@ -142,42 +142,44 @@ resource "aws_instance" "hoge" {
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_instance.hoge"=> {
"type"=> "aws_instance",
"primary"=> {
"id"=> "i-1234abcd",
"attributes"=> {
"ami"=> "ami-1234abcd",
"associate_public_ip_address"=> "true",
"availability_zone"=> "ap-northeast-1b",
"ebs_block_device.#"=> "1",
"ebs_optimized"=> "false",
"ephemeral_block_device.#"=> "0",
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_instance.hoge"=> {
"type"=> "aws_instance",
"primary"=> {
"id"=> "i-1234abcd",
"instance_type"=> "t2.micro",
"private_dns"=> "ip-10-0-0-100.ap-northeast-1.compute.internal",
"private_ip"=> "10.0.0.100",
"public_dns"=> "ec2-54-12-0-0.ap-northeast-1.compute.amazonaws.com",
"public_ip"=> "54.12.0.0",
"root_block_device.#"=> "1",
"security_groups.#"=> "1",
"source_dest_check"=> "true",
"subnet_id"=> "subnet-1234abcd",
"tenancy"=> "default"
},
"meta"=> {
"schema_version"=> "1"
"attributes"=> {
"ami"=> "ami-1234abcd",
"associate_public_ip_address"=> "true",
"availability_zone"=> "ap-northeast-1b",
"ebs_block_device.#"=> "1",
"ebs_optimized"=> "false",
"ephemeral_block_device.#"=> "0",
"id"=> "i-1234abcd",
"instance_type"=> "t2.micro",
"private_dns"=> "ip-10-0-0-100.ap-northeast-1.compute.internal",
"private_ip"=> "10.0.0.100",
"public_dns"=> "ec2-54-12-0-0.ap-northeast-1.compute.amazonaws.com",
"public_ip"=> "54.12.0.0",
"root_block_device.#"=> "1",
"security_groups.#"=> "1",
"source_dest_check"=> "true",
"subnet_id"=> "subnet-1234abcd",
"tenancy"=> "default"
},
"meta"=> {
"schema_version"=> "1"
}
}
}
}
}
}
]
})
end
end
......
......@@ -228,58 +228,60 @@ resource "aws_elb" "fuga" {
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_elb.hoge" => {
"type" => "aws_elb",
"primary" => {
"id" => "hoge",
"attributes" => {
"availability_zones.#" => "2",
"connection_draining" => "true",
"connection_draining_timeout" => "300",
"cross_zone_load_balancing" => "true",
"dns_name" => "hoge-12345678.ap-northeast-1.elb.amazonaws.com",
"health_check.#" => "1",
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_elb.hoge" => {
"type" => "aws_elb",
"primary" => {
"id" => "hoge",
"idle_timeout" => "60",
"instances.#" => "1",
"listener.#" => "1",
"name" => "hoge",
"security_groups.#" => "2",
"source_security_group" => "default",
"subnets.#" => "2",
"attributes" => {
"availability_zones.#" => "2",
"connection_draining" => "true",
"connection_draining_timeout" => "300",
"cross_zone_load_balancing" => "true",
"dns_name" => "hoge-12345678.ap-northeast-1.elb.amazonaws.com",
"health_check.#" => "1",
"id" => "hoge",
"idle_timeout" => "60",
"instances.#" => "1",
"listener.#" => "1",
"name" => "hoge",
"security_groups.#" => "2",
"source_security_group" => "default",
"subnets.#" => "2",
}
}
}
},
"aws_elb.fuga" => {
"type" => "aws_elb",
"primary" => {
"id" => "fuga",
"attributes" => {
"availability_zones.#" => "2",
"connection_draining" => "true",
"connection_draining_timeout" => "900",
"cross_zone_load_balancing" => "true",
"dns_name" => "fuga-90123456.ap-northeast-1.elb.amazonaws.com",
"health_check.#" => "1",
},
"aws_elb.fuga" => {
"type" => "aws_elb",
"primary" => {
"id" => "fuga",
"idle_timeout" => "90",
"instances.#" => "1",
"listener.#" => "1",
"name" => "fuga",
"security_groups.#" => "2",
"source_security_group" => "elb",
"subnets.#" => "2",
"attributes" => {
"availability_zones.#" => "2",
"connection_draining" => "true",
"connection_draining_timeout" => "900",
"cross_zone_load_balancing" => "true",
"dns_name" => "fuga-90123456.ap-northeast-1.elb.amazonaws.com",
"health_check.#" => "1",
"id" => "fuga",
"idle_timeout" => "90",
"instances.#" => "1",
"listener.#" => "1",
"name" => "fuga",
"security_groups.#" => "2",
"source_security_group" => "elb",
"subnets.#" => "2",
}
}
}
}
}
}
]
})
end
end
......
......@@ -98,38 +98,40 @@ POLICY
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_iam_group_policy.hoge_policy" => {
"type" => "aws_iam_group_policy",
"primary" => {
"id" => "hoge:hoge_policy",
"attributes" => {
"group" => "hoge",
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_iam_group_policy.hoge_policy" => {
"type" => "aws_iam_group_policy",
"primary" => {
"id" => "hoge:hoge_policy",
"name" => "hoge_policy",
"policy" => "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": [\n \"ec2:Describe*\"\n ],\n \"Effect\": \"Allow\",\n \"Resource\": \"*\"\n }\n ]\n}\n",
"attributes" => {
"group" => "hoge",
"id" => "hoge:hoge_policy",
"name" => "hoge_policy",
"policy" => "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": [\n \"ec2:Describe*\"\n ],\n \"Effect\": \"Allow\",\n \"Resource\": \"*\"\n }\n ]\n}\n",
}
}
}
},
"aws_iam_group_policy.fuga_policy" => {
"type" => "aws_iam_group_policy",
"primary" => {
"id" => "fuga:fuga_policy",
"attributes" => {
"group" => "fuga",
},
"aws_iam_group_policy.fuga_policy" => {
"type" => "aws_iam_group_policy",
"primary" => {
"id" => "fuga:fuga_policy",
"name" => "fuga_policy",
"policy" => "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": [\n \"ec2:Describe*\"\n ],\n \"Effect\": \"Allow\",\n \"Resource\": \"*\"\n }\n ]\n}\n",
"attributes" => {
"group" => "fuga",
"id" => "fuga:fuga_policy",
"name" => "fuga_policy",
"policy" => "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": [\n \"ec2:Describe*\"\n ],\n \"Effect\": \"Allow\",\n \"Resource\": \"*\"\n }\n ]\n}\n",
}
}
}
},
},
}
}
}
]
})
end
end
......
......@@ -52,40 +52,42 @@ resource "aws_iam_group" "fuga" {
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_iam_group.hoge" => {
"type" => "aws_iam_group",
"primary" => {
"id" => "hoge",
"attributes" => {
"arn"=> "arn:aws:iam::123456789012:group/hoge",
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_iam_group.hoge" => {
"type" => "aws_iam_group",
"primary" => {
"id" => "hoge",
"name" => "hoge",
"path" => "/",
"unique_id" => "ABCDEFGHIJKLMN1234567",
"attributes" => {
"arn"=> "arn:aws:iam::123456789012:group/hoge",
"id" => "hoge",
"name" => "hoge",
"path" => "/",
"unique_id" => "ABCDEFGHIJKLMN1234567",
}
}
}
},
"aws_iam_group.fuga" => {
"type" => "aws_iam_group",
"primary" => {
"id" => "fuga",
"attributes" => {
"arn"=> "arn:aws:iam::345678901234:group/fuga",
},
"aws_iam_group.fuga" => {
"type" => "aws_iam_group",
"primary" => {
"id" => "fuga",
"name" => "fuga",
"path" => "/system/",
"unique_id" => "OPQRSTUVWXYZA8901234",
"attributes" => {
"arn"=> "arn:aws:iam::345678901234:group/fuga",
"id" => "fuga",
"name" => "fuga",
"path" => "/system/",
"unique_id" => "OPQRSTUVWXYZA8901234",
}
}
}
},
},
}
}
}
]
})
end
end
......
......@@ -107,38 +107,40 @@ POLICY
expect(described_class.tfstate(client)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 1,
"modules" => {
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_iam_policy.hoge_policy" => {
"type" => "aws_iam_policy",
"primary" => {
"id" => "arn:aws:iam::123456789012:policy/hoge_policy",
"attributes" => {
"modules" => [
{
"path" => [
"root"
],
"outputs" => {},
"resources" => {
"aws_iam_policy.hoge_policy" => {
"type" => "aws_iam_policy",
"primary" => {
"id" => "arn:aws:iam::123456789012:policy/hoge_policy",
"name" => "hoge_policy",
"path" => "/",
"policy" => "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": [\n \"ec2:Describe*\"\n ],\n \"Effect\": \"Allow\",\n \"Resource\": \"*\"\n }\n ]\n}\n",
"attributes" => {
"id" => "arn:aws:iam::123456789012:policy/hoge_policy",
"name" => "hoge_policy",
"path" => "/",
"policy" => "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Action\": [\n \"ec2:Describe*\"\n ],\n \"Effect\": \"Allow\",\n \"Resource\": \"*\"\n }\n ]\n}\n",
}
}
}
},
"aws_iam_policy.fuga_policy" => {
"type" =>