Skip to content

Commit

Permalink
Merge pull request #8241 from kirkbyers/kbye/#7441-redshift-timeouts
Browse files Browse the repository at this point in the history
#7441 redshift resource create/update/delete timeouts
  • Loading branch information
bflad authored Apr 10, 2019
2 parents f7f2f8f + 55f5f5b commit 6ae498c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
16 changes: 11 additions & 5 deletions aws/resource_aws_redshift_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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,
}

Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_redshift_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
9 changes: 9 additions & 0 deletions website/docs/r/redshift_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 6ae498c

Please sign in to comment.