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

'update_policy' variable for MIG submodule requires parameters that have conflicts. #405

Closed
dmytropakki1995 opened this issue May 20, 2024 · 1 comment
Labels
bug Something isn't working Stale

Comments

@dmytropakki1995
Copy link

dmytropakki1995 commented May 20, 2024

TL;DR

Hello there!
I created a Managed Instance Group with module 11.1.0.
After that, I use update_policy to add configuration for rolling update policy.

Expected behavior

terraform plan must trigger changes and show changes for update_policy.

Observed behavior

Get the error:

Error: Invalid value for input variable
│ 
│   on main.tf line 71, in module "mig":
│   71:   update_policy = [
│   72:     {
│   73:       type                           = "PROACTIVE"
│   74:       instance_redistribution_type   = "PROACTIVE"
│   75:       minimal_action                 = "REPLACE"
│   76:       most_disruptive_allowed_action = "REPLACE"
│   77:       max_unavailable_fixed          = 1
│   78:       max_surge_fixed                = 1
│   79:       replacement_method             = "SUBSTITUTE"
│   80:     }
│   81:   ]
│ 
│ The given value is not suitable for module.nonprod_carbon_sunup_mig.var.update_policy declared at .terraform/modules/mig/modules/mig/variables.tf:100,1-25: element 0: attributes "max_surge_percent",
│ "max_unavailable_percent", and "min_ready_sec" are required.

update_policy variable is defined as:

variable "update_policy" {
  description = "The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy"
  type = list(object({
    max_surge_fixed                = number
    instance_redistribution_type   = string
    max_surge_percent              = number
    max_unavailable_fixed          = number
    max_unavailable_percent        = number
    min_ready_sec                  = number
    replacement_method             = string
    minimal_action                 = string
    type                           = string
    most_disruptive_allowed_action = string
  }))
  default = []
}

It means that this variable expects the list of maps where each map contains all these keys.
With respect to the documentation https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_region_instance_group_manager#nested_update_policy we cannot define all keys simultaneously because some of them have conflicts with each other.

Terraform Configuration

module "mig" {
  source  = "terraform-google-modules/vm/google//modules/mig"
  version = "11.1.0"

  instance_template = google_compute_instance_template.test_template.self_link
  region            = "us-central1"
  project_id        = "test-project"
  hostname          = "test-hostname"
  target_size       = 2
  
  distribution_policy_zones = ["us-central1-a", "us-central1-f"]
  
  named_ports = [
    { 
      name = "http"
      port = 80
    }
  ]

  update_policy = [
    {
      type                           = "PROACTIVE"
      instance_redistribution_type   = "PROACTIVE"
      minimal_action                 = "REPLACE"
      most_disruptive_allowed_action = "REPLACE"
      max_unavailable_fixed          = 1
      max_surge_fixed                = 1
      replacement_method             = "SUBSTITUTE"
    }
  ]
}

Terraform Version

v1.4.7

Additional information

No response

@dmytropakki1995 dmytropakki1995 added the bug Something isn't working label May 20, 2024
@dmytropakki1995 dmytropakki1995 changed the title 'update_policy' variable requires parameters that are Conflicts 'update_policy' variable requires parameters that have conflicts. May 20, 2024
@dmytropakki1995 dmytropakki1995 changed the title 'update_policy' variable requires parameters that have conflicts. 'update_policy' variable for MIG submodule requires parameters that have conflicts. May 20, 2024
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Jul 19, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

1 participant