Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plan modifiers to stop showing values that didn't change on TF plan #154

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

posriniv
Copy link
Collaborator

@posriniv posriniv commented Jan 30, 2025

Today, when we run terraform plan we show all the computed attributed though they didn't change. It makes it difficult to properly identify the attributes that didn't change. Plan modifiers come to our rescue here helping us hide the computed attributes from the plan.

For example, here is the plan after changing num_cores before the change was done:

bash-5.2$ terraform plan
ybm_allow_list.mylist: Refreshing state...
ybm_cluster.single_region: Refreshing state...

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # ybm_cluster.single_region will be updated in-place
  ~ resource "ybm_cluster" "single_region" {
      ~ account_id             = "5379da8e-9248-42f4-bd25-ebd7341eae69" -> (known after apply)
      ~ backup_schedules       = [
          ~ {
              ~ backup_description       = "Default backup schedule" -> (known after apply)
              + cron_expression          = (known after apply)
              ~ schedule_id              = "d97a8d18-2d59-48f6-a7f7-5d9620ce9541" -> (known after apply)
                # (3 unchanged attributes hidden)
            },
        ]
      ~ cluster_certificate    = <<-EOT
            -----BEGIN CERTIFICATE-----
            redacted
            ------------------------------
        EOT -> (known after apply)
      ~ cluster_endpoints      = {
          - "us-west2" = "us-west2.dae29dd9-14e7-42fd-9da9-df98a1f21b62.gcp.devcloud.yugabyte.com"
        } -> (known after apply)
      ~ cluster_id             = "dae29dd9-14e7-42fd-9da9-df98a1f21b62" -> (known after apply)
      ~ cluster_info           = {
          ~ created_time     = "2025-01-29T21:36:45.425Z" -> (known after apply)
          ~ software_version = "2024.1.4.0-b108" -> (known after apply)
          ~ state            = "ACTIVE" -> (known after apply)
          ~ updated_time     = "2025-01-29T21:46:42.364Z" -> (known after apply)
        } -> (known after apply)
      ~ cluster_region_info    = [
          ~ {
              ~ disk_iops     = 0 -> (known after apply)
              ~ disk_size_gb  = 100 -> (known after apply)
              ~ is_default    = true -> (known after apply)
              ~ is_preferred  = false -> (known after apply)
              ~ num_cores     = 2 -> 4
              ~ public_access = true -> (known after apply)
              + vpc_id        = (known after apply)
              + vpc_name      = (known after apply)
                # (2 unchanged attributes hidden)
            },
        ]
      ~ cluster_version        = "8" -> (known after apply)
      ~ database_track         = "Innovation" -> (known after apply)
      ~ desired_state          = "Active" -> (known after apply)
      ~ endpoints              = [
          - {
              - accessibility_type = "PUBLIC" -> null
              - host               = "us-west2.dae29dd9-14e7-42fd-9da9-df98a1f21b62.gcp.devcloud.yugabyte.com" -> null
              - region             = "us-west2" -> null
            },
        ] -> (known after apply)
      ~ node_config            = {
          ~ disk_iops    = 0 -> (known after apply)
          ~ disk_size_gb = 100 -> (known after apply)
          ~ num_cores    = 2 -> (known after apply)
        } -> (known after apply)
      ~ num_faults_to_tolerate = 0 -> (known after apply)
      ~ project_id             = "847ad1d5-2eaa-46f5-8528-cca023d1f540" -> (known after apply)
        # (7 unchanged attributes hidden)
    }

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

Here is it after the change is done:

bash-5.2$ terraform plan
ybm_allow_list.mylist: Refreshing state...
ybm_cluster.single_region: Refreshing state...

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # ybm_cluster.single_region will be updated in-place
  ~ resource "ybm_cluster" "single_region" {
      ~ cluster_region_info    = [
          ~ {
              ~ num_cores     = 2 -> 4
                # (9 unchanged attributes hidden)
            },
        ]
        # (20 unchanged attributes hidden)
    }

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

@posriniv posriniv merged commit 47202c4 into main Jan 31, 2025
2 checks passed
@posriniv posriniv deleted the fix-incorrect-plans branch January 31, 2025 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants