From c1eee521f3b5deab57e4ba2738a609b67869fabb Mon Sep 17 00:00:00 2001 From: djuke Date: Mon, 30 May 2016 00:01:58 +0200 Subject: [PATCH] reading the aws instance it was assumed that eth0 was the first in the list of network interfaces (#6761) --- builtin/providers/aws/resource_aws_instance.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index cc44e7328..e43a20b10 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -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) }