Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Fix support for EIP in EC2-Classic #316

Merged
merged 1 commit into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/terraforming/resource/eip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def tfstate
attributes = {
"association_id" => addr.association_id,
"domain" => addr.domain,
"id" => addr.allocation_id,
"id" => vpc?(addr) ? addr.allocation_id : addr.public_ip,
"instance" => addr.instance_id,
"network_interface" => addr.network_interface_id,
"private_ip" => addr.private_ip_address,
Expand All @@ -35,7 +35,7 @@ def tfstate
resources["aws_eip.#{module_name_of(addr)}"] = {
"type" => "aws_eip",
"primary" => {
"id" => addr.allocation_id,
"id" => vpc?(addr) ? addr.allocation_id : addr.public_ip,
"attributes" => attributes
}
}
Expand All @@ -55,7 +55,11 @@ def vpc?(addr)
end

def module_name_of(addr)
normalize_module_name(addr.allocation_id)
if vpc?(addr)
normalize_module_name(addr.allocation_id)
else
normalize_module_name(addr.public_ip)
end
end
end
end
Expand Down
28 changes: 28 additions & 0 deletions spec/lib/terraforming/resource/eip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ module Resource
domain: "vpc",
allocation_id: "eipalloc-33333333",
},
{
instance_id: "i-91112221",
public_ip: "2.2.2.4",
allocation_id: nil,
association_id: nil,
domain: "standard",
network_interface_id: nil,
network_interface_owner_id: nil,
private_ip_address: nil
}
]
end

Expand All @@ -57,6 +67,11 @@ module Resource
vpc = true
}

resource "aws_eip" "2-2-2-4" {
instance = "i-91112221"
vpc = false
}

EOS
end
end
Expand Down Expand Up @@ -107,6 +122,19 @@ module Resource
}
}
},
"aws_eip.2-2-2-4" => {
"type" => "aws_eip",
"primary" => {
"id" => "2.2.2.4",
"attributes" => {
"domain" => "standard",
"id" => "2.2.2.4",
"instance" => "i-91112221",
"public_ip" => "2.2.2.4",
"vpc" => "false"
},
},
},
})
end
end
Expand Down