From dde1073d4a840eaf732dbb22d1d2765ff4f9cb86 Mon Sep 17 00:00:00 2001
From: James Nugent <james@jen20.com>
Date: Wed, 29 May 2019 12:02:42 -0500
Subject: [PATCH] aws_subnet: Increase timeout for delete to 20 mins

We've seen subnet deletion failures that we think we can trace to ENIs left
behind by NLB. We don't have permission to detach or delete those ENIs, so our
only recourse is to wait longer.

Additionally, we plumb through Create and Delete to use the configured timeouts
via `d.Timeout(schema.Timeout{Create,Delete})` so that custom timeouts will be
reflected. Update is not as straightforward to reason about as there are
separate timeouts for disassociation and association of address spaces, and the
individually configured values do not appear to have presented problems so far.
---
 aws/resource_aws_subnet.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/aws/resource_aws_subnet.go b/aws/resource_aws_subnet.go
index 9941b75eb38..a6fa266e7c9 100644
--- a/aws/resource_aws_subnet.go
+++ b/aws/resource_aws_subnet.go
@@ -24,7 +24,7 @@ func resourceAwsSubnet() *schema.Resource {
 
 		Timeouts: &schema.ResourceTimeout{
 			Create: schema.DefaultTimeout(10 * time.Minute),
-			Delete: schema.DefaultTimeout(10 * time.Minute),
+			Delete: schema.DefaultTimeout(20 * time.Minute),
 		},
 
 		SchemaVersion: 1,
@@ -129,7 +129,7 @@ func resourceAwsSubnetCreate(d *schema.ResourceData, meta interface{}) error {
 		Pending: []string{"pending"},
 		Target:  []string{"available"},
 		Refresh: SubnetStateRefreshFunc(conn, *subnet.SubnetId),
-		Timeout: 10 * time.Minute,
+		Timeout: d.Timeout(schema.TimeoutCreate),
 	}
 
 	_, err = stateConf.WaitForState()
@@ -330,7 +330,7 @@ func resourceAwsSubnetDelete(d *schema.ResourceData, meta interface{}) error {
 	wait := resource.StateChangeConf{
 		Pending:    []string{"pending"},
 		Target:     []string{"destroyed"},
-		Timeout:    10 * time.Minute,
+		Timeout:    d.Timeout(schema.TimeoutDelete),
 		MinTimeout: 1 * time.Second,
 		Refresh: func() (interface{}, string, error) {
 			_, err := conn.DeleteSubnet(req)