From d41c9d46a818d27551a5dc0d5b088b7d50a9743b Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 11 Jun 2015 07:59:42 -0500 Subject: [PATCH] provider/aws: ignore empty vpc_security_group_ids fixes #2293 --- builtin/providers/aws/resource_aws_instance.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index 71a04aea9..5ac89b4a5 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -539,8 +539,8 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error { if d.HasChange("vpc_security_group_ids") { var groups []*string - if v := d.Get("vpc_security_group_ids"); v != nil { - for _, v := range v.(*schema.Set).List() { + if v := d.Get("vpc_security_group_ids").(*schema.Set); v.Len() > 0 { + for _, v := range v.List() { groups = append(groups, aws.String(v.(string))) } } @@ -908,8 +908,8 @@ func buildAwsInstanceOpts( ni.PrivateIPAddress = aws.String(v.(string)) } - if v := d.Get("vpc_security_group_ids"); v != nil { - for _, v := range v.(*schema.Set).List() { + if v := d.Get("vpc_security_group_ids").(*schema.Set); v.Len() > 0 { + for _, v := range v.List() { ni.Groups = append(ni.Groups, aws.String(v.(string))) } } @@ -930,8 +930,8 @@ func buildAwsInstanceOpts( opts.SecurityGroups = groups } - if v := d.Get("vpc_security_group_ids"); v != nil { - for _, v := range v.(*schema.Set).List() { + if v := d.Get("vpc_security_group_ids").(*schema.Set); v.Len() > 0 { + for _, v := range v.List() { opts.SecurityGroupIDs = append(opts.SecurityGroupIDs, aws.String(v.(string))) } }