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.
This commit is contained in:
Zachary Salzbank 2016-07-25 14:52:40 -04:00 committed by Paul Stack
parent fcfb7f4e1b
commit afb06f907f
2 changed files with 8 additions and 0 deletions

View File

@ -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 != "" {

View File

@ -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