-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r/aws_redshift_cluster: 'cluster_node_ips' -> 'cluster_nodes'.
- Loading branch information
Showing
7 changed files
with
456 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package redshift | ||
|
||
// https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html#rs-mgmt-cluster-status. | ||
const ( | ||
ClusterStatusAvailable = "available" | ||
ClusterStatusAvailablePrepForResize = "available, prep-for-resize" | ||
ClusterStatusAvailableResizeCleanup = "available, resize-cleanup" | ||
ClusterStatusCancellingResize = "cancelling-resize" | ||
ClusterStatusCreating = "creating" | ||
ClusterStatusDeleting = "deleting" | ||
ClusterStatusFinalSnapshot = "final-snapshot" | ||
ClusterStatusHardwareFailure = "hardware-failure" | ||
ClusterStatusIncompatibleHsm = "incompatible-hsm" | ||
ClusterStatusIncompatibleNetwork = "incompatible-network" | ||
ClusterStatusIncompatibleParameters = "incompatible-parameters" | ||
ClusterStatusIncompatibleRestore = "incompatible-restore" | ||
ClusterStatusModifying = "modifying" | ||
ClusterStatusPaused = "paused" | ||
ClusterStatusRebooting = "rebooting" | ||
ClusterStatusRenaming = "renaming" | ||
ClusterStatusResizing = "resizing" | ||
ClusterStatusRotatingKeys = "rotating-keys" | ||
ClusterStatusStorageFull = "storage-full" | ||
ClusterStatusUpdatingHsm = "updating-hsm" | ||
) | ||
|
||
const ( | ||
ClusterTypeMultiNode = "multi-node" | ||
ClusterTypeSingleNode = "single-node" | ||
) | ||
|
||
func ClusterType_Values() []string { | ||
return []string{ | ||
ClusterTypeMultiNode, | ||
ClusterTypeSingleNode, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package finder | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/redshift" | ||
"github.com/hashicorp/aws-sdk-go-base/tfawserr" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource" | ||
) | ||
|
||
func ClusterByID(conn *redshift.Redshift, id string) (*redshift.Cluster, error) { | ||
input := &redshift.DescribeClustersInput{ | ||
ClusterIdentifier: aws.String(id), | ||
} | ||
|
||
output, err := conn.DescribeClusters(input) | ||
|
||
if tfawserr.ErrCodeEquals(err, redshift.ErrCodeClusterNotFoundFault) { | ||
return nil, &resource.NotFoundError{ | ||
LastError: err, | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil || len(output.Clusters) == 0 || output.Clusters[0] == nil { | ||
return nil, tfresource.NewEmptyResultError(input) | ||
} | ||
|
||
if count := len(output.Clusters); count > 1 { | ||
return nil, tfresource.NewTooManyResultsError(count, input) | ||
} | ||
|
||
return output.Clusters[0], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package waiter | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/redshift" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/redshift/finder" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource" | ||
) | ||
|
||
func ClusterStatus(conn *redshift.Redshift, id string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
output, err := finder.ClusterByID(conn, id) | ||
|
||
if tfresource.NotFound(err) { | ||
return nil, "", nil | ||
} | ||
|
||
if err != nil { | ||
return nil, "", err | ||
} | ||
|
||
return output, aws.StringValue(output.ClusterStatus), nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package waiter | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/service/redshift" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
tfredshift "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/redshift" | ||
) | ||
|
||
const ( | ||
ClusterInvalidClusterStateFaultTimeout = 15 * time.Minute | ||
) | ||
|
||
func ClusterDeleted(conn *redshift.Redshift, id string, timeout time.Duration) (*redshift.Cluster, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{ | ||
tfredshift.ClusterStatusAvailable, | ||
tfredshift.ClusterStatusCreating, | ||
tfredshift.ClusterStatusDeleting, | ||
tfredshift.ClusterStatusFinalSnapshot, | ||
tfredshift.ClusterStatusRebooting, | ||
tfredshift.ClusterStatusRenaming, | ||
tfredshift.ClusterStatusResizing, | ||
}, | ||
Target: []string{}, | ||
Refresh: ClusterStatus(conn, id), | ||
Timeout: timeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if output, ok := outputRaw.(*redshift.Cluster); ok { | ||
return output, err | ||
} | ||
|
||
return nil, err | ||
} |
Oops, something went wrong.