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

b/aws_redshift_cluster: Adds retries to enabling and disabling the redshift cluster's logging #22080

Merged
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
3 changes: 3 additions & 0 deletions .changelog/22080.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_redshift_cluster: Adds retries to enabling and disabling the redshift cluster's logging
```
28 changes: 22 additions & 6 deletions internal/service/redshift/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,18 @@ func resourceClusterUpdate(d *schema.ResourceData, meta interface{}) error {
}
} else {
log.Printf("[INFO] Disabling Logging for Redshift Cluster %q", d.Id())
_, err := conn.DisableLogging(&redshift.DisableLoggingInput{
ClusterIdentifier: aws.String(d.Id()),
})
_, err := tfresource.RetryWhenAWSErrCodeEquals(
clusterInvalidClusterStateFaultTimeout,
func() (interface{}, error) {
return conn.DisableLogging(&redshift.DisableLoggingInput{
ClusterIdentifier: aws.String(d.Id()),
})
},
redshift.ErrCodeInvalidClusterStateFault,
)

if err != nil {
return err
return fmt.Errorf("error disabling Redshift Cluster (%s) logging: %w", d.Id(), err)
}
}
}
Expand All @@ -830,9 +837,18 @@ func enableRedshiftClusterLogging(d *schema.ResourceData, conn *redshift.Redshif
params.S3KeyPrefix = aws.String(v.(string))
}

if _, err := conn.EnableLogging(params); err != nil {
return fmt.Errorf("error enabling Redshift Cluster (%s) logging: %s", d.Id(), err)
_, err := tfresource.RetryWhenAWSErrCodeEquals(
clusterInvalidClusterStateFaultTimeout,
func() (interface{}, error) {
return conn.EnableLogging(params)
},
redshift.ErrCodeInvalidClusterStateFault,
)

if err != nil {
return fmt.Errorf("error enabling Redshift Cluster (%s) logging: %w", d.Id(), err)
}

return nil
}

Expand Down