terraform-google-modules / terraform-google-memorystore

Creates a fully functional Google Memorystore (redis) instance
https://registry.terraform.io/modules/terraform-google-modules/memorystore/google
Apache License 2.0
43 stars 98 forks source link

Recreation of redis cluster when run new terraform plan and apply #220

Open lanandra opened 1 week ago

lanandra commented 1 week ago

TL;DR

Recreation of redis cluster although no updated configurations on module block

Expected behavior

When there is no updated configurations, terraform plan and terraform apply should find no drift and no need to recreate the cluster

Observed behavior

I am using module/submodule terraform-google-modules/memorystore/google//modules/redis-cluster version 9.0

The behavior what i observed are:

Terraform Configuration

module "redis_cluster" {
  source  = "terraform-google-modules/memorystore/google//modules/redis-cluster"
  version = "~> 9.0"

  name        = var.memorystore_name
  project     = var.project_id
  region      = var.default_region
  network     = ["projects/${var.project_id}/global/networks/${var.environment}"]
  node_type   = var.node_type
  shard_count = var.shard_count

  service_connection_policies = var.service_connection_policies

  redis_configs = {
    maxmemory-policy = var.maxmemory_policy
  }
}

Terraform Version

1.7.0

Additional information

No response

lanandra commented 3 days ago

example of the recreation of redis cluster:

21:02:30    # google_redis_cluster.redis_cluster must be replaced
21:02:30  -/+ resource "google_redis_cluster" "redis_cluster" {
21:02:30        ~ create_time             = "2024-07-01T13:44:29.096602051Z" -> (known after apply)
21:02:30        ~ discovery_endpoints     = [
21:02:30            - {
21:02:30                - address    = "10.158.192.14"
21:02:30                - port       = 6379
21:02:30                - psc_config = [
21:02:30                    - {
21:02:30                        - network = "projects/project-id/global/networks/network-id"
21:02:30                      },
21:02:30                  ]
21:02:30              },
21:02:30          ] -> (known after apply)
21:02:30        ~ id                      = "projects/project-id/locations/us-central1/clusters/memorystore-name" -> (known after apply)
21:02:30          name                    = "memorystore-name"
21:02:30        ~ precise_size_gb         = 19.5 -> (known after apply)
21:02:30        ~ psc_connections         = [
21:02:30            - {
21:02:30                - address           = "10.158.192.14"
21:02:30                - forwarding_rule   = "https://www.googleapis.com/compute/v1/projects/project-id/regions/us-central1/forwardingRules/rule-id"
21:02:30                - network           = "projects/project-id/global/networks/network-id"
21:02:30                - project_id        = "project-id"
21:02:30                - psc_connection_id = "connection-id"
21:02:30              },
21:02:30            - {
21:02:30                - address           = "10.158.192.4"
21:02:30                - forwarding_rule   = "https://www.googleapis.com/compute/v1/projects/project-id/regions/us-central1/forwardingRules/rule-id"
21:02:30                - network           = "projects/project-id/global/networks/network-id"
21:02:30                - project_id        = "project-id"
21:02:30                - psc_connection_id = "connection-id"
21:02:30              },
21:02:30          ] -> (known after apply)
21:02:30        - replica_count           = 0 -> null
21:02:30        ~ size_gb                 = 20 -> (known after apply)
21:02:30        ~ state                   = "ACTIVE" -> (known after apply)
21:02:30        ~ state_info              = [] -> (known after apply)
21:02:30        ~ uid                     = "uid" -> (known after apply)
21:02:30          # (7 unchanged attributes hidden)
21:02:30  
21:02:30        - zone_distribution_config { # forces replacement
21:02:30            - mode = "MULTI_ZONE" -> null
21:02:30          }
21:02:30  
21:02:30          # (1 unchanged block hidden)
21:02:30      }
21:02:30  
21:02:30  Plan: 1 to add, 0 to change, 1 to destroy.

Found out zone_distribution_config that force the replacement