Add Elastic Network Interfaces as route destination

Fixes #938
This commit is contained in:
duncan 2015-04-17 13:18:46 -04:00
parent e3a6fab501
commit e1ac4b9f90
2 changed files with 17 additions and 3 deletions

View File

@ -53,6 +53,11 @@ func resourceAwsRouteTable() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"network_interface_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
},
},
Set: resourceAwsRouteTableHash,
@ -141,6 +146,9 @@ func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error {
if r.VPCPeeringConnectionID != nil {
m["vpc_peering_connection_id"] = *r.VPCPeeringConnectionID
}
if r.NetworkInterfaceID != nil {
m["network_interface_id"] = *r.NetworkInterfaceID
}
route.Add(m)
}
@ -192,6 +200,7 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
GatewayID: aws.String(m["gateway_id"].(string)),
InstanceID: aws.String(m["instance_id"].(string)),
VPCPeeringConnectionID: aws.String(m["vpc_peering_connection_id"].(string)),
NetworkInterfaceID: aws.String(m["network_interface_id"].(string)),
}
log.Printf("[INFO] Creating route for %s: %#v", d.Id(), opts)
@ -289,6 +298,10 @@ func resourceAwsRouteTableHash(v interface{}) int {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
}
if v, ok := m["network_interface_id"]; ok {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
}
return hashcode.String(buf.String())
}

View File

@ -40,10 +40,11 @@ Each route supports the following:
* `gateway_id` - (Optional) The Internet Gateway ID.
* `instance_id` - (Optional) The EC2 instance ID.
* `vpc_peering_connection_id` - (Optional) The VPC Peering ID.
* `network_interface_id` - (Optional) The ID of the elastic network interface (eni) to use.
Each route must contain either a `gateway_id`, an `instance_id` or a `vpc_peering_connection_id`. Note that the
default route, mapping the VPC's CIDR block to "local", is created implicitly and
cannot be specified.
Each route must contain either a `gateway_id`, an `instance_id` or a `vpc_peering_connection_id`
or a `network_interface_id`. Note that the default route, mapping the VPC's CIDR block to "local",
is created implicitly and cannot be specified.
## Attributes Reference