Open jagada1010 opened 3 weeks ago
Hi @jagada1010!
According to the error, the problem is that the maintenance_policy
attribute of the google_redis_cluster
resource is receiving an invalid value. According to the API documentation this argument is expecting an object and is being given a value = null
. In terraform, JSON, TypeScript and JavaScript you can do this depending on the internal specifications, but the correct way is to return an empty object like this example:
maintenance_policy = {}
Could you try this configuration again instead of using maintenance_policy = null
?
Hi @ggtisc.
Thank you for your response. But I am still getting the same error.
This seems more like a troubleshooting issue than a bug. I have changed the variables that you share for their values, simplifying the code no errors have been obtained. Below I share the used code:
resource "google_compute_network" "cn_20187" {
name = "cn-20187"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "subnetwork_20187" {
name = "subnetwork-20187"
ip_cidr_range = "10.0.0.248/29"
region = "us-central1"
network = google_compute_network.cn_20187.id
}
resource "google_network_connectivity_service_connection_policy" "network_connectivity_service_connection_policy_20187" {
name = "network-connectivity-service-connection-policy-20187"
location = "us-central1"
service_class = "gcp-memorystore-redis"
description = "something"
network = google_compute_network.cn_20187.id
psc_config {
subnetworks = [google_compute_subnetwork.subnetwork_20187.id]
}
}
resource "google_redis_cluster" "redis_cluster_20187" {
project = "my-project"
name = "redis-cluster-20187"
shard_count = 3
region = "us-central1"
replica_count = 1
transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED"
authorization_mode = "AUTH_MODE_DISABLED"
node_type = "REDIS_STANDARD_SMALL"
deletion_protection_enabled = false
redis_configs = {}
psc_configs {
network = google_compute_network.cn_20187.id
}
zone_distribution_config {
mode = "MULTI_ZONE"
zone = null
}
maintenance_policy {
weekly_maintenance_window {
day = "FRIDAY"
start_time {
hours = 2
minutes = 0
seconds = 0
nanos = 0
}
}
}
timeouts {
create = "60m"
}
}
You could try again substituting the variables with their values ββuntil you find the value(s) you are entering which is/are causing this error. For this I also suggest you review the documentation and confirm that each value meets the requirements for both, the terraform registry and the API.
This is a real bug.
The problem is that this MMv1 template generates the field_mask
code but only use the top level property changes, i.e. maintenance_policy
instead of maintenance_policy.weekly_maintenance_window
, maintenance_window
, or maintenance_policy.deny_maintenance_periods
.
After some tries I can't replicate this issue. I'm forwarding this issue for a deep review and verify if it is an intermittent bug
Community Note
Terraform Version & Provider Version(s)
Terraform v6.9.0 on
Affected Resource(s)
google_redis_cluster
Terraform Configuration
Debug Output
Expected Behavior
module.redis_cluster["redis-poc-002"].google_redis_cluster.redis_cluster will be updated in-place
~ resource "google_redis_cluster" "redis_cluster" { id = "projects/**/locations/us-central1/clusters/redis-poc-002" name = "redis-poc-002"
(18 unchanged attributes hidden)
Plan: 0 to add, 1 to change, 0 to destroy.
The hour in the maintenance policy's start time should have changed from 2 to 3 hours. Same error with day argument in weekly_maintenance_window should have changed from FRIDAY to THURSDAY.
Actual Behavior
No change happened instead got this error : module.redis_cluster["redis-poc-002"].google_redis_cluster.redis_cluster: Modifying... [id=projects/prj--**--poc/locations/us-central1/clusters/redis-poc-002] β· β Error: Error updating Cluster "projects/**/locations/us-central1/clusters/redis-poc-002": googleapi: Error 400: unsupported path in fieldMask: maintenance_policy. Allowed values are persistence_config, deletion_protection_enabled, maintenance_policy.weekly_maintenance_window, cross_cluster_replication_config, display_name, shard_count, replica_count, redis_configs, maintenance_window, maintenance_policy.deny_maintenance_periods, cluster_endpoints β Details: β [ β { β "@type": "type.googleapis.com/google.rpc.BadRequest", β "fieldViolations": [ β { β "field": "maintenance_policy" β } β ] β } β ] β β with module.redis_cluster["redis-poc-002"].google_redis_cluster.redis_cluster, β on ..\Module\main.tf line 1, in resource "google_redis_cluster" "redis_cluster": β 1: resource "google_redis_cluster" "redis_cluster" {
Steps to reproduce
terraform apply
Important Factoids
I am able to attach the maintenance policy during the creation of the Redis cluster but once it's created I can't add or edit the existing maintenance policy.
References
https://github.com/hashicorp/terraform-provider-google/issues/20101
b/380246854