Merge pull request #1575 from freshbooks/aws-eni-route

provider/aws: Add Elastic Network Interfaces as route destination
This commit is contained in:
Mitchell Hashimoto 2015-05-05 13:28:48 -07:00
commit 412a2dca0b
2 changed files with 17 additions and 3 deletions

View File

@ -53,6 +53,11 @@ func resourceAwsRouteTable() *schema.Resource {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
}, },
"network_interface_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
}, },
}, },
Set: resourceAwsRouteTableHash, Set: resourceAwsRouteTableHash,
@ -141,6 +146,9 @@ func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error {
if r.VPCPeeringConnectionID != nil { if r.VPCPeeringConnectionID != nil {
m["vpc_peering_connection_id"] = *r.VPCPeeringConnectionID m["vpc_peering_connection_id"] = *r.VPCPeeringConnectionID
} }
if r.NetworkInterfaceID != nil {
m["network_interface_id"] = *r.NetworkInterfaceID
}
route.Add(m) route.Add(m)
} }
@ -192,6 +200,7 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
GatewayID: aws.String(m["gateway_id"].(string)), GatewayID: aws.String(m["gateway_id"].(string)),
InstanceID: aws.String(m["instance_id"].(string)), InstanceID: aws.String(m["instance_id"].(string)),
VPCPeeringConnectionID: aws.String(m["vpc_peering_connection_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) 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))) 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()) return hashcode.String(buf.String())
} }

View File

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