How to fix Error: Error creating Redshift Cluster: ClusterAlreadyExists in Terraform

TerraformINTERMEDIATEMEDIUMUpdated Dec 31, 2025ยท 97 views

The ClusterAlreadyExists error occurs when Terraform attempts to create a Redshift cluster with an identifier that already exists in your AWS account. Since cluster identifiers must be unique within an account and region, this error indicates the cluster was previously created or still exists from a failed operation.

Quick fix

Fixes ClusterAlreadyExists

aws redshift describe-clusters --cluster-identifier my-cluster-name --region us-east-1
  1. Verify the cluster exists in AWS
  2. Import the existing cluster into Terraform state
  3. Check Terraform state for conflicts
  4. Use a unique cluster identifier
terraform โ€” error
aws redshift describe-clusters --cluster-identifier my-cluster-name --region us-east-1
Error: Error creating Redshift Cluster: ClusterAlreadyExists

What this error means

The ClusterAlreadyExists error means the cluster identifier you specified is already in use in your AWS account. Redshift cluster identifiers must be unique within each AWS account and region. When Terraform attempts to create a new cluster with an identifier that's already assigned, AWS rejects the operation to prevent resource conflicts. The identifier persists even if the cluster is being deleted or is in an error state.

Typical symptoms

  • Terraform apply fails when creating aws_redshift_cluster resource
  • Error message shows "ClusterAlreadyExists" or "cluster already exists"
  • The specific cluster identifier cannot be reused
  • AWS Redshift console shows the cluster exists or is in deletion state
  • Previous failed Terraform runs may have left the cluster in an intermediate state
  • Cluster was created outside of Terraform (via Console or CLI)
  • Terraform state is out of sync with actual AWS resources

Common causes

  1. The cluster identifier was used in a previous successful Terraform run but state was lost or reset
  2. The cluster was created manually in AWS Console or via AWS CLI outside Terraform management
  3. A previous Terraform apply partially completed, leaving the cluster in a pending or intermediate state
  4. Another team member created a cluster with the same identifier in the same AWS account
  5. The cluster still exists despite being marked for deletion due to AWS cleanup delays
  6. Terraform state file does not reflect the actual clusters present in AWS
  7. A failed apply did not clean up the partially created cluster before exiting

How to fix "Error: Error creating Redshift Cluster: ClusterAlreadyExists"

1Verify the cluster exists in AWS

Confirm the cluster is actually present in your AWS account and region:

bash
aws redshift describe-clusters --cluster-identifier my-cluster-name --region us-east-1

If the command returns cluster details, the cluster exists. If it returns a ClusterNotFound error, the cluster may be in a transient deletion state.

2Import the existing cluster into Terraform state

If you own the cluster and want Terraform to manage it, import it into your state:

bash
terraform import aws_redshift_cluster.my_cluster my-cluster-name

Replace "my_cluster" with your resource name and "my-cluster-name" with the actual cluster identifier. This brings the existing cluster under Terraform management without modifying it.

3Check Terraform state for conflicts

List Redshift resources in your state to see what is already tracked:

bash
terraform state list | grep redshift_cluster
terraform state show aws_redshift_cluster.my_cluster

If the resource exists in state, remove it and re-import:

bash
terraform state rm aws_redshift_cluster.my_cluster
terraform import aws_redshift_cluster.my_cluster my-cluster-name
4Use a unique cluster identifier

Modify your Terraform configuration to use a different cluster identifier that is not already in use:

hcl
resource "aws_redshift_cluster" "my_cluster" {
  cluster_identifier = "my-cluster-${formatdate("YYYY-MM-DD-hhmm", timestamp())}"
  database_name      = "mydb"
  master_username    = "admin"
  node_type          = "dc2.large"
  number_of_nodes    = 2
}

Cluster identifiers must be 1-63 alphanumeric characters (lowercase) and unique within your account.

5Wait for cluster deletion to complete

If the cluster is in a deletion state, wait for AWS to fully remove it before retrying:

bash
aws redshift describe-clusters --cluster-identifier my-cluster-name --region us-east-1

Repeat this command until it returns a ClusterNotFound error. Cluster deletion can take 5-15 minutes. Once deleted, you can reuse the identifier.

6Delete the cluster if you own it (optional)

If you want to recreate the cluster from scratch, delete it first:

bash
aws redshift delete-cluster --cluster-identifier my-cluster-name --skip-final-cluster-snapshot --region us-east-1

Use --final-cluster-snapshot-identifier to save a snapshot before deletion. After deletion completes, you can run terraform apply to create a new cluster with the same identifier.

Advanced notes

## Redshift Cluster Identifier Rules
- Must be 1-63 alphanumeric characters
- First character must be a letter
- Lowercase letters only
- Cannot end with a hyphen
- Cannot contain two consecutive hyphens
- Must be unique within your AWS account and region

## State Drift and Recovery
If Terraform state becomes out of sync due to manual cluster modifications, use terraform refresh to update state without making changes:

bash
terraform refresh

This polls AWS for the current state of all tracked resources and updates your local state file.

## Deletion Timing
Cluster deletion is asynchronous in AWS. The cluster may show as "deleting" for several minutes. During this time, the identifier is still reserved and cannot be reused. Plan accordingly when deleting and recreating clusters.

## Multi-Cluster Deployments
When managing multiple Redshift clusters in the same Terraform configuration, use unique identifiers for each one:

hcl
resource "aws_redshift_cluster" "analytics" {
  cluster_identifier = "analytics-cluster"
}

resource "aws_redshift_cluster" "reporting" {
  cluster_identifier = "reporting-cluster"
}

Never attempt to create two resources with the same cluster_identifier in the same or different regions.

Frequently asked questions

What does "ClusterAlreadyExists" mean?
The ClusterAlreadyExists error means the cluster identifier you specified is already in use in your AWS account. Redshift cluster identifiers must be unique within each AWS account and region. When Terraform attempts to create a new cluster with an identifier that's already assigned, AWS rejects the operation to prevent resource conflicts.
How do I fix "ClusterAlreadyExists"?
The ClusterAlreadyExists error occurs when Terraform attempts to create a Redshift cluster with an identifier that already exists in your AWS account. Since cluster identifiers must be unique within an account and region, this error indicates the cluster was previously created or still exists from a failed operation.
What causes "ClusterAlreadyExists"?
The cluster identifier was used in a previous successful Terraform run but state was lost or reset The cluster was created manually in AWS Console or via AWS CLI outside Terraform management A previous Terraform apply partially completed, leaving the cluster in a pending or intermediate state
Is the "ClusterAlreadyExists" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading