diff --git a/aws/resource_aws_security_group.go b/aws/resource_aws_security_group.go index 9c8426e39ca..245e2de3a41 100644 --- a/aws/resource_aws_security_group.go +++ b/aws/resource_aws_security_group.go @@ -346,7 +346,7 @@ func resourceAwsSecurityGroupCreate(d *schema.ResourceData, meta interface{}) er } - return resourceAwsSecurityGroupUpdate(d, meta) + return resourceAwsSecurityGroupUpdateExisting(d, meta) } func resourceAwsSecurityGroupRead(d *schema.ResourceData, meta interface{}) error { @@ -405,7 +405,11 @@ func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) er group := sgRaw.(*ec2.SecurityGroup) - err = resourceAwsSecurityGroupUpdateRules(d, "ingress", meta, group) + return resourceAwsSecurityGroupUpdateExisting(group, d, meta) +} + +func resourceAwsSecurityGroupUpdateExisting(group *ec2.SecurityGroup, d *schema.ResourceData, meta interface{}) error { + err := resourceAwsSecurityGroupUpdateRules(d, "ingress", meta, group) if err != nil { return err } @@ -418,6 +422,7 @@ func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) er } if !d.IsNewResource() { + conn := meta.(*AWSClient).ec2conn if err := setTags(conn, d); err != nil { return err }