Commit f7f6cca7 authored by sakazuki's avatar sakazuki

cover other cases

parent f07c6a4f
......@@ -24,6 +24,11 @@ module Terraforming
execute(Terraforming::Resource::EC2, options)
end
desc "eip", "EIP"
def eip
execute(Terraforming::Resource::EIP, options)
end
desc "ecc", "ElastiCache Cluster"
def ecc
execute(Terraforming::Resource::ElastiCacheCluster, options)
......
......@@ -29,8 +29,9 @@ module Terraforming
"network_interface" => addr.network_interface_id,
"private_ip" => addr.private_ip_address,
"public_ip" => addr.public_ip,
"vpc" => addr.domain.eql?("vpc"),
"vpc" => is_vpc?(addr),
}
attributes.delete_if{|k, v| v.nil?}
resources["aws_eip.#{addr.allocation_id}"] = {
"type" => "aws_eip",
"primary" => {
......@@ -48,6 +49,10 @@ module Terraforming
def eips
@client.describe_addresses.addresses
end
def is_vpc?(addr)
addr.domain.eql?("vpc")
end
end
end
end
<% eips.each do |addr| -%>
resource "aws_eip" "<%= addr.allocation_id %>" {
<% if addr.instance_id -%>
instance = "<%= addr.instance_id %>"
vpc = <%= addr.domain.eql?("vpc") %>
<% elsif addr.network_interface_id -%>
network_interface_id = "<%= addr.network_interface_id %>"
<% end -%>
<% if addr.instance_id || addr.network_interface_id -%>
vpc = <%= is_vpc?(addr) %>
<% end -%>
}
<% end -%>
......@@ -21,7 +21,6 @@ module Terraforming
},
{
domain: "vpc",
instance_id: "i-23456789",
network_interface_id: "eni-23456789",
association_id: "eipassoc-87654321",
network_interface_owner_id: "234567890123",
......@@ -29,6 +28,11 @@ module Terraforming
allocation_id: "eipalloc-76543210",
private_ip_address: "9.9.9.9",
},
{
public_ip: "3.3.3.3",
domain: "vpc",
allocation_id: "eipalloc-33333333",
},
]
end
......@@ -45,10 +49,13 @@ resource "aws_eip" "eipalloc-87654321" {
}
resource "aws_eip" "eipalloc-76543210" {
instance = "i-23456789"
network_interface_id = "eni-23456789"
vpc = true
}
resource "aws_eip" "eipalloc-33333333" {
}
EOS
end
end
......@@ -81,7 +88,6 @@ resource "aws_eip" "eipalloc-76543210" {
"association_id" => "eipassoc-87654321",
"domain" => "vpc",
"id" => "eipalloc-76543210",
"instance" => "i-23456789",
"network_interface" => "eni-23456789",
"private_ip" => "9.9.9.9",
"public_ip" => "2.2.2.2",
......@@ -89,6 +95,18 @@ resource "aws_eip" "eipalloc-76543210" {
}
}
},
"aws_eip.eipalloc-33333333" => {
"type" => "aws_eip",
"primary" => {
"id" => "eipalloc-33333333",
"attributes" => {
"domain" => "vpc",
"id" => "eipalloc-33333333",
"public_ip" => "3.3.3.3",
"vpc" => true,
}
}
},
})
end
end
......
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