terraform-provider-google: Setting redis maintenance_policy causes creation of unexpected config block of maintenance_schedule

Community Note

  • Please vote on this issue by adding a šŸ‘ reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.13.7

Affected Resource(s)

resource ā€œgoogle_redis_instanceā€

Terraform Configuration Files

resource "google_redis_instance" "cache_instance" {
  name           = "cache-instance"
  tier           = "STANDARD_HA"
  memory_size_gb = 2

  location_id             = local.gcp_zones[0]
  alternative_location_id = local.gcp_zones[1]
  authorized_network      = local.network
  connect_mode            = "PRIVATE_SERVICE_ACCESS"
  labels                  = local.labels

  maintenance_policy {
    weekly_maintenance_window {
      day = "SUNDAY"
      start_time {
        hours = 9
      }
    }
  }
}

Debug Output

https://gist.github.com/yonicurv/1a9006c0ec9bee33f4ce13c01f19835d

Expected Behavior

Do not try to remove scheduled maintenance.

Actual Behavior

Tries to remove and fails with : Error 400: Invalid option ā€˜maintenance_schedule’: ā€˜maintenance_schedule’ cannot be updated on existing instances.

Steps to Reproduce

  1. terraform apply
  2. Let GCP to schedule next maintenance.
  3. terraform apply

Workaround

Add the following block to ignore any changes related to maintenance_schedule, and preserve the configuration of maintenance_policy for future schedules.

  lifecycle {
    ignore_changes = [
      maintenance_schedule,
    ]
  }

References

https://github.com/hashicorp/terraform-provider-google/pull/10978 https://github.com/hashicorp/terraform-provider-google/issues/9622

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 43
  • Comments: 16

Commits related to this issue

Most upvoted comments

Lifecycle worked for me, as a temporary solution.

lifecycle {
ignore_changes = [ maintenance_schedule, ] }

Is there any solution to this other than ignoring the changes?