confluentinc / terraform-provider-confluent

Terraform Provider for Confluent
Apache License 2.0
118 stars 61 forks source link

Flink compute resource thinks it needs to be recreated #324

Closed brbrown25 closed 8 months ago

brbrown25 commented 8 months ago

Using provider version 1.54.0 I created a flink cluster with

resource "confluent_flink_compute_pool" "flink-poc" {
  display_name = "Flink-POC"
  cloud        = "AWS"
  region       = "us-east-1"
  max_cfu      = 5
  environment {
    id = module.confluent_cloud.confluent_environment_id
  }
  lifecycle {
    prevent_destroy = true
  }
}

and ran terraform apply -target=confluent_flink_compute_pool.flink-poc this created the cluster just fine. However now I'm making other changes and receiving

Error: Instance cannot be destroyed

  on flink.tf line 1:
   1: resource "confluent_flink_compute_pool" "flink-poc" {

Resource confluent_flink_compute_pool.flink-poc has lifecycle.prevent_destroy
set, but the plan calls for this resource to be destroyed. To avoid this error
and continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.

So I switching prevent_destroy to be false and it shows the following plan

  # confluent_flink_compute_pool.flink-poc must be replaced
-/+ resource "confluent_flink_compute_pool" "flink-poc" {
      ~ api_version   = "fcpm/v2" -> (known after apply)
      ~ cloud         = "aws" -> "AWS" # forces replacement
      ~ current_cfu   = 0 -> (known after apply)
        display_name  = "Flink-POC"
      ~ id            = "lfcp-xr98y1" -> (known after apply)
      ~ kind          = "ComputePool" -> (known after apply)
        max_cfu       = 5
        region        = "us-east-1"
      ~ resource_name = "crn://confluent.cloud/organization=5326eae9-de11-480a-8150-7530332fbec6/environment=env-5gr58/flink-region=aws.us-east-1/compute-pool=lfcp-xr98y1" -> (known after apply)
      ~ rest_endpoint = "https://flink.us-east-1.aws.confluent.cloud/sql/v1beta1/organizations/5326eae9-de11-480a-8150-7530332fbec6/environments/env-5gr58" -> (known after apply)

        environment {
            id = "env-5gr58"
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.

So it looks like it's going to change the cloud even though it is all uppercase and has been the whole time

linouk23 commented 8 months ago

@brbrown25 thanks for reporting the issue!

We're aware of this regression and our backend team merged a fix internally and it should be deployed early next week.

linouk23 commented 8 months ago

As a quick workaround, I'd recommend using ignore_changes lifecycle attribute:

resource "confluent_flink_compute_pool" "flink-poc" {
  display_name = "Flink-POC"
  cloud        = "AWS"
  region       = "us-east-1"
  max_cfu      = 5
  environment {
    id = module.confluent_cloud.confluent_environment_id
  }
  lifecycle {
    prevent_destroy = true
    ignore_changes = [
      # Ignore changes to cloud
      cloud,
    ]
  }
}
brbrown25 commented 8 months ago

Awesome, thank you @linouk23!

linouk23 commented 8 months ago

@brbrown25 I believe the backend team merged a fix, but we also released a client-side fix in version 1.55.0, which we have just released:

image