Unable to delete Redshift Cluster because it require a FinalSnapshotIdentifier

Hi,

I created a module for Redshift, it works very well until today when i wanted to do a destroy. I’m getting this error :

Error: Redshift Cluster Instance FinalSnapshotIdentifier is required when a final snapshot is required

Terraform Version

0.12.9

Terraform Configuration Files

This is my code :

resource "aws_redshift_cluster" "redshift" {
  cluster_identifier                  = "${var.project}-${var.cluster_name}-redshift-${var.environment}"
  database_name                    = "${var.db_name}"
  port                                      = "${var.db_port}"
  master_username                     = "${var.db_master_username}"
  master_password                     = "${random_string.db_password.result}"
  node_type                           = "${var.node_type}"
  cluster_type                        = "${var.cluster_type}"
  number_of_nodes                     = "${var.number_of_nodes}"
  automated_snapshot_retention_period = "${var.automated_snapshot_retention_period}"

  publicly_accessible       = "${var.publicly_accessible}"
  vpc_security_group_ids    = "${var.security_groups}"
  cluster_subnet_group_name = "${aws_redshift_subnet_group.subnet.id}"
  iam_roles                 = "${var.iam_roles}"

  snapshot_cluster_identifier = var.snapshot_cluster_identifier != "" ? var.snapshot_cluster_identifier : null

  lifecycle { ignore_changes = ["tags.DateTimeTag"] }

}

I tried to add :

skip_final_snapshot = true

But i got the same error.

Expected Behavior

The cluster deleted

Actual Behavior

The cluster is not deleted due to the error !

**

Error: Redshift Cluster Instance FinalSnapshotIdentifier is required when a final snapshot is required

**

Hi @hdryx!

I’m not familiar with this resource type in particular, but I wonder if this is happening because the skip_final_snapshot argument you changed must be applied (using terraform apply) before you destroy it.

When Terraform plans a destroy operation, it does not evaluate the configuration again. Instead, it just plans to destroy the object currently recorded in the state. I think that if you run terraform apply first here, the provider will then update the state to include skip_final_snapshot = true so that a subsequent terraform destroy can see it.

1 Like

@apparentlymart you are correct. Adding that flag, then applying and only then destroying works.