Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7441 redshift resource create/update/delete timeouts #8241

Merged
merged 2 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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