Skip to content

Commit

Permalink
Merge pull request #3599 from domdom82/sg_timeout
Browse files Browse the repository at this point in the history
add configurable timeouts to security groups
  • Loading branch information
bflad authored Mar 5, 2018
2 parents a92f507 + 2f26a53 commit 600a133
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions aws/resource_aws_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ func resourceAwsSecurityGroup() *schema.Resource {
State: resourceAwsSecurityGroupImportState,
},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},

SchemaVersion: 1,
MigrateState: resourceAwsSecurityGroupMigrateState,

Expand Down Expand Up @@ -274,7 +279,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()
Expand Down Expand Up @@ -443,7 +448,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()),
})
Expand Down Expand Up @@ -1281,7 +1286,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(
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/security_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 600a133

Please sign in to comment.