From e1ac4b9f9036dcdb0ec01419b4664691393b73c8 Mon Sep 17 00:00:00 2001 From: duncan Date: Fri, 17 Apr 2015 13:18:46 -0400 Subject: [PATCH] Add Elastic Network Interfaces as route destination Fixes #938 --- builtin/providers/aws/resource_aws_route_table.go | 13 +++++++++++++ .../docs/providers/aws/r/route_table.html.markdown | 7 ++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route_table.go b/builtin/providers/aws/resource_aws_route_table.go index 3265696bf..40c50a8cc 100644 --- a/builtin/providers/aws/resource_aws_route_table.go +++ b/builtin/providers/aws/resource_aws_route_table.go @@ -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()) } diff --git a/website/source/docs/providers/aws/r/route_table.html.markdown b/website/source/docs/providers/aws/r/route_table.html.markdown index 9d25e9779..c47455398 100644 --- a/website/source/docs/providers/aws/r/route_table.html.markdown +++ b/website/source/docs/providers/aws/r/route_table.html.markdown @@ -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