From afb06f907ff58f9a13345dfd48a40cda36e774a9 Mon Sep 17 00:00:00 2001 From: Zachary Salzbank Date: Mon, 25 Jul 2016 14:52:40 -0400 Subject: [PATCH] providers/aws: expose network interface id (#6751) Expose the network interface ID that is created with a new instance. This can be useful when associating an existing elastic IP to the default interface on an instance that has multiple network interfaces. --- builtin/providers/aws/resource_aws_instance.go | 7 +++++++ website/source/docs/providers/aws/r/instance.html.markdown | 1 + 2 files changed, 8 insertions(+) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index 892235965c..ebd6111092 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -128,6 +128,11 @@ func resourceAwsInstance() *schema.Resource { Computed: true, }, + "network_interface_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "public_ip": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -488,10 +493,12 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error { for _, ni := range instance.NetworkInterfaces { if *ni.Attachment.DeviceIndex == 0 { d.Set("subnet_id", ni.SubnetId) + d.Set("network_interface_id", ni.NetworkInterfaceId) } } } else { d.Set("subnet_id", instance.SubnetId) + d.Set("network_interface_id", "") } d.Set("ebs_optimized", instance.EbsOptimized) if instance.SubnetId != nil && *instance.SubnetId != "" { diff --git a/website/source/docs/providers/aws/r/instance.html.markdown b/website/source/docs/providers/aws/r/instance.html.markdown index 5681109b5e..67d9ec85e9 100644 --- a/website/source/docs/providers/aws/r/instance.html.markdown +++ b/website/source/docs/providers/aws/r/instance.html.markdown @@ -152,6 +152,7 @@ The following attributes are exported: * `public_dns` - The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC * `public_ip` - The public IP address assigned to the instance, if applicable. **NOTE**: If you are using an [`aws_eip`](/docs/providers/aws/r/eip.html) with your instance, you should refer to the EIP's address directly and not use `public_ip`, as this field will change after the EIP is attached. +* `network_interface_id` - The ID of the network interface that was created with the instance. * `private_dns` - The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC