From c05d7410c6e0838a2862084dc7a2f50117734df4 Mon Sep 17 00:00:00 2001 From: Dominik Froehlich Date: Thu, 1 Mar 2018 17:40:01 +0100 Subject: [PATCH 1/3] add configurable timeouts to security groups --- aws/resource_aws_security_group.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_security_group.go b/aws/resource_aws_security_group.go index 9c8426e39ca..17d71878450 100644 --- a/aws/resource_aws_security_group.go +++ b/aws/resource_aws_security_group.go @@ -27,6 +27,12 @@ func resourceAwsSecurityGroup() *schema.Resource { State: resourceAwsSecurityGroupImportState, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(10 * time.Minute), + Update: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + SchemaVersion: 1, MigrateState: resourceAwsSecurityGroupMigrateState, @@ -274,7 +280,7 @@ func resourceAwsSecurityGroupCreate(d *schema.ResourceData, meta interface{}) er Pending: []string{""}, Target: []string{"exists"}, Refresh: SGStateRefreshFunc(conn, d.Id()), - Timeout: 10 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), } resp, err := stateConf.WaitForState() @@ -443,7 +449,7 @@ func resourceAwsSecurityGroupDelete(d *schema.ResourceData, meta interface{}) er } } - return resource.Retry(5*time.Minute, func() *resource.RetryError { + return resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { _, err := conn.DeleteSecurityGroup(&ec2.DeleteSecurityGroupInput{ GroupId: aws.String(d.Id()), }) @@ -1281,7 +1287,7 @@ func deleteLingeringLambdaENIs(conn *ec2.EC2, d *schema.ResourceData) error { Pending: []string{"true"}, Target: []string{"false"}, Refresh: networkInterfaceAttachedRefreshFunc(conn, *eni.NetworkInterfaceId), - Timeout: 10 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), } if _, err := stateConf.WaitForState(); err != nil { return fmt.Errorf( From 44d5e6857090194ca8d25176169775c90c73bc75 Mon Sep 17 00:00:00 2001 From: Dominik Froehlich Date: Sat, 3 Mar 2018 09:03:20 +0100 Subject: [PATCH 2/3] remove update timeout --- aws/resource_aws_security_group.go | 1 - 1 file changed, 1 deletion(-) diff --git a/aws/resource_aws_security_group.go b/aws/resource_aws_security_group.go index 17d71878450..7751f1dd19a 100644 --- a/aws/resource_aws_security_group.go +++ b/aws/resource_aws_security_group.go @@ -29,7 +29,6 @@ func resourceAwsSecurityGroup() *schema.Resource { Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(10 * time.Minute), - Update: schema.DefaultTimeout(10 * time.Minute), Delete: schema.DefaultTimeout(10 * time.Minute), }, From 2f26a5302647434aa939f93224be6f4cf7e68fb1 Mon Sep 17 00:00:00 2001 From: Dominik Froehlich Date: Sat, 3 Mar 2018 09:10:04 +0100 Subject: [PATCH 3/3] add documentation --- website/docs/r/security_group.html.markdown | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/website/docs/r/security_group.html.markdown b/website/docs/r/security_group.html.markdown index e9b1b73b283..bfae84839b6 100644 --- a/website/docs/r/security_group.html.markdown +++ b/website/docs/r/security_group.html.markdown @@ -167,6 +167,13 @@ The following attributes are exported: * `ingress` - The ingress rules. See above for more. * `egress` - The egress rules. See above for more. +## Timeouts + +`aws_security_group` provides the following [Timeouts](/docs/configuration/resources.html#timeouts) +configuration options: + +- `create` - (Default `10 minutes`) How long to wait for a security group to be created. +- `delete` - (Default `10 minutes`) How long to wait for a security group to be deleted. ## Import