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:
parent
fcfb7f4e1b
commit
afb06f907f
|
@ -128,6 +128,11 @@ func resourceAwsInstance() *schema.Resource {
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"network_interface_id": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
"public_ip": &schema.Schema{
|
"public_ip": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
@ -488,10 +493,12 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
for _, ni := range instance.NetworkInterfaces {
|
for _, ni := range instance.NetworkInterfaces {
|
||||||
if *ni.Attachment.DeviceIndex == 0 {
|
if *ni.Attachment.DeviceIndex == 0 {
|
||||||
d.Set("subnet_id", ni.SubnetId)
|
d.Set("subnet_id", ni.SubnetId)
|
||||||
|
d.Set("network_interface_id", ni.NetworkInterfaceId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
d.Set("subnet_id", instance.SubnetId)
|
d.Set("subnet_id", instance.SubnetId)
|
||||||
|
d.Set("network_interface_id", "")
|
||||||
}
|
}
|
||||||
d.Set("ebs_optimized", instance.EbsOptimized)
|
d.Set("ebs_optimized", instance.EbsOptimized)
|
||||||
if instance.SubnetId != nil && *instance.SubnetId != "" {
|
if instance.SubnetId != nil && *instance.SubnetId != "" {
|
||||||
|
|
|
@ -152,6 +152,7 @@ The following attributes are exported:
|
||||||
* `public_dns` - The public DNS name assigned to the instance. For EC2-VPC, this
|
* `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
|
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.
|
* `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
|
* `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
|
used inside the Amazon EC2, and only available if you've enabled DNS hostnames
|
||||||
for your VPC
|
for your VPC
|
||||||
|
|
Loading…
Reference in New Issue