diff --git a/builtin/providers/aws/resource_aws_security_group.go b/builtin/providers/aws/resource_aws_security_group.go index 8905b6f8fa..14d57d6207 100644 --- a/builtin/providers/aws/resource_aws_security_group.go +++ b/builtin/providers/aws/resource_aws_security_group.go @@ -205,10 +205,15 @@ func SGStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc { sgs := []ec2.SecurityGroup{ec2.SecurityGroup{Id: id}} resp, err := conn.SecurityGroups(sgs, nil) if err != nil { - if ec2err, ok := err.(*ec2.Error); ok && - ec2err.Code == "InvalidSecurityGroupID.NotFound" { - resp = nil - } else { + if ec2err, ok := err.(*ec2.Error); ok { + if ec2err.Code == "InvalidSecurityGroupID.NotFound" || + ec2err.Code == "InvalidGroup.NotFound" { + resp = nil + err = nil + } + } + + if err != nil { log.Printf("Error on SGStateRefresh: %s", err) return nil, "", err }