reading the aws instance it was assumed that eth0 was the first in the list of network interfaces (#6761)

This commit is contained in:
djuke 2016-05-30 00:01:58 +02:00 committed by Radek Simko
parent f3a3cfab73
commit c1eee521f3
1 changed files with 5 additions and 1 deletions

View File

@ -488,7 +488,11 @@ func resourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("iam_instance_profile", iamInstanceProfileArnToName(instance.IamInstanceProfile))
if len(instance.NetworkInterfaces) > 0 {
d.Set("subnet_id", instance.NetworkInterfaces[0].SubnetId)
for _, ni := range instance.NetworkInterfaces {
if *ni.Attachment.DeviceIndex == 0 {
d.Set("subnet_id", ni.SubnetId)
}
}
} else {
d.Set("subnet_id", instance.SubnetId)
}