From 0c93afedcd3a659cad4cc22d9b3931f00f90b8ab Mon Sep 17 00:00:00 2001 From: kirkbyers Date: Sun, 7 Apr 2019 17:56:26 -0500 Subject: [PATCH 1/2] Add configurable timeouts to redshift create, update, and delete. --- aws/resource_aws_redshift_cluster.go | 16 +++++++++++----- aws/resource_aws_redshift_cluster_test.go | 4 ++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/aws/resource_aws_redshift_cluster.go b/aws/resource_aws_redshift_cluster.go index 8044ea207bf..3b3378a4bef 100644 --- a/aws/resource_aws_redshift_cluster.go +++ b/aws/resource_aws_redshift_cluster.go @@ -25,6 +25,12 @@ func resourceAwsRedshiftCluster() *schema.Resource { State: resourceAwsRedshiftClusterImport, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(75 * time.Minute), + Update: schema.DefaultTimeout(40 * time.Minute), + Delete: schema.DefaultTimeout(40 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "database_name": { Type: schema.TypeString, @@ -481,7 +487,7 @@ func resourceAwsRedshiftClusterCreate(d *schema.ResourceData, meta interface{}) Pending: []string{"creating", "backing-up", "modifying", "restoring"}, Target: []string{"available"}, Refresh: resourceAwsRedshiftClusterStateRefreshFunc(d.Id(), conn), - Timeout: 75 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), MinTimeout: 10 * time.Second, } @@ -759,7 +765,7 @@ func resourceAwsRedshiftClusterUpdate(d *schema.ResourceData, meta interface{}) Pending: []string{"creating", "deleting", "rebooting", "resizing", "renaming", "modifying"}, Target: []string{"available"}, Refresh: resourceAwsRedshiftClusterStateRefreshFunc(d.Id(), conn), - Timeout: 40 * time.Minute, + Timeout: d.Timeout(schema.TimeoutUpdate), MinTimeout: 10 * time.Second, } @@ -872,7 +878,7 @@ func resourceAwsRedshiftClusterDelete(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Deleting Redshift Cluster: %s", deleteOpts) - err := deleteAwsRedshiftCluster(&deleteOpts, conn) + err := deleteAwsRedshiftCluster(&deleteOpts, conn, d.Timeout(schema.TimeoutDelete)) if err != nil { return err } @@ -882,7 +888,7 @@ func resourceAwsRedshiftClusterDelete(d *schema.ResourceData, meta interface{}) return nil } -func deleteAwsRedshiftCluster(opts *redshift.DeleteClusterInput, conn *redshift.Redshift) error { +func deleteAwsRedshiftCluster(opts *redshift.DeleteClusterInput, conn *redshift.Redshift, timeout time.Duration) error { id := *opts.ClusterIdentifier log.Printf("[INFO] Deleting Redshift Cluster %q", id) err := resource.Retry(15*time.Minute, func() *resource.RetryError { @@ -901,7 +907,7 @@ func deleteAwsRedshiftCluster(opts *redshift.DeleteClusterInput, conn *redshift. Pending: []string{"available", "creating", "deleting", "rebooting", "resizing", "renaming", "final-snapshot"}, Target: []string{"destroyed"}, Refresh: resourceAwsRedshiftClusterStateRefreshFunc(id, conn), - Timeout: 40 * time.Minute, + Timeout: timeout, MinTimeout: 5 * time.Second, } diff --git a/aws/resource_aws_redshift_cluster_test.go b/aws/resource_aws_redshift_cluster_test.go index 7200c2f228b..d347ccf4a66 100644 --- a/aws/resource_aws_redshift_cluster_test.go +++ b/aws/resource_aws_redshift_cluster_test.go @@ -922,6 +922,10 @@ resource "aws_redshift_cluster" "default" { automated_snapshot_retention_period = 0 allow_version_upgrade = false skip_final_snapshot = true + + timeouts { + create = "30m" + } }`, rInt) } From 55f5f5b2ad7cccfc7b46d9fb34f84f3e8907a324 Mon Sep 17 00:00:00 2001 From: kirkbyers Date: Sun, 7 Apr 2019 18:03:39 -0500 Subject: [PATCH 2/2] Update redshift cluster doc with Timeouts. --- website/docs/r/redshift_cluster.html.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/docs/r/redshift_cluster.html.markdown b/website/docs/r/redshift_cluster.html.markdown index 1d67aa8c6bb..fbe89b9147d 100644 --- a/website/docs/r/redshift_cluster.html.markdown +++ b/website/docs/r/redshift_cluster.html.markdown @@ -73,6 +73,15 @@ string. * `snapshot_copy` - (Optional) Configuration of automatic copy of snapshots from one region to another. Documented below. * `tags` - (Optional) A mapping of tags to assign to the resource. +### Timeouts + +`aws_redshift_cluster` provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - (Default `75 minutes`) Used for creating Clusters. +- `update` - (Default `40 minutes`) Used for Cluster Argument changes. +- `delete` - (Default `40 minutes`) Used for destroying Clusters. + ### Nested Blocks #### `logging`