Skip to content

Commit

Permalink
Adds retries to enabling and disabling the redshift cluster's logging…
Browse files Browse the repository at this point in the history
…. Solves issue - hashicorp#21815
  • Loading branch information
larssnellman committed Dec 7, 2021
1 parent 5827ef2 commit 4f095bf
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions internal/service/redshift/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,16 @@ 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(
5*time.Minute,
func() (interface{}, error) {
return conn.DisableLogging(&redshift.DisableLoggingInput{
ClusterIdentifier: aws.String(d.Id()),
})
},
redshift.ErrCodeInvalidClusterStateFault,
)

if err != nil {
return 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 {
_, err := tfresource.RetryWhenAWSErrCodeEquals(
5*time.Minute,
func() (interface{}, error) {
return conn.EnableLogging(params)
},
redshift.ErrCodeInvalidClusterStateFault,
)

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

return nil
}

Expand Down

0 comments on commit 4f095bf

Please sign in to comment.