Terraform-provider-google: Argument Not Expected - Master Authorised Networks CIDR Blocks

Created on 26 Jul 2019  ·  3Comments  ·  Source: hashicorp/terraform-provider-google


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: 0.12.4
Google Provider: 2.11.0

Affected Resource(s)

  • google_container_cluster

Terraform Configuration Files

resource "google_container_cluster" "cluster" {
  name = "${var.name}"

  # What zones should we run in
  location = "${var.primary_zone}"
  enable_legacy_abac = false

  initial_node_count =  1
  node_config {
    machine_type = "${var.machine["type"]}"
    disk_size_gb = "100"
    oauth_scopes = "${var.gke_node_scopes}"
    preemptible  = false
  }
  remove_default_node_pool =  true

  lifecycle {
    ignore_changes = ["initial_node_count", "network_policy", "node_config", "addons_config[0].horizontal_pod_autoscaling", "node_version"]
  }

  master_authorized_networks_config {
    cidr_blocks = [
      {
        cidr_block = "1.2.3.4/32",
        display_name = "redacted"
      },
      {
        cidr_block = "1.2.3.4/32",
        display_name = "redacted"
      },
      {
        cidr_block = "1.2.3.4/32",
        display_name = "redacted"
      }
    ]
  }

  # Enable network policy for custom rules
  network_policy {
    enabled = false
    provider = "CALICO"
  }

  # Network configuration
  network = "${var.network}"
  subnetwork = "${google_compute_subnetwork.vpc_regional_subnet.name}"

  # Logging and monitoring configuration
  monitoring_service = "none"
  logging_service = "none"

  min_master_version = "${var.kubernetes_version}"
  node_version = "${var.kubernetes_version}"

  # Add on configuration
  addons_config {
    http_load_balancing {
      disabled = true
    }
    horizontal_pod_autoscaling {
      disabled = true
    }
    kubernetes_dashboard {
      disabled = true
    }
  }

  ip_allocation_policy {
    cluster_secondary_range_name = "${var.name}-pods"
    services_secondary_range_name = "${var.name}-services"
  }

  timeouts {
    create = "10m"
    delete = "30m"
    update = "2h"
  }
}

Expected Behavior

Plan should complete successfully as it does on pre 0.12 TF versions

Actual Behavior

Error: Unsupported argument

  on modules/container-cluster/main.tf line 115, in resource "google_container_cluster" "cluster":
 115:     cidr_blocks = [

An argument named "cidr_blocks" is not expected here. Did you mean to define a
block of type "cidr_blocks"?

Steps to Reproduce

  1. Create the above resource on a pre 0.12 version of Terraform & providers
  2. Update to Terraform 0.12 & respective providers
  3. terraform plan

References

There was some discussion about this here but it's unclear where it ended up: https://github.com/hashicorp/terraform/issues/20505

bug

Most helpful comment

As mentioned in the terraform 0.12 upgrade guide, you can no longer use the cidr_blocks = [{ ... }] attribute format in your config files, you need to use the cidr_blocks { } block format.

This is, unfortunately, outside the control of the provider and is documented behavior, so I'm going to close this issue out, but if you have further issues or I've misunderstood what's going on here, please feel free to reply and I can take a look again.

All 3 comments

Looks to work with the below instead

  master_authorized_networks_config {
    cidr_blocks {
      cidr_block = "1.2.3.4/32"
      display_name = "redacted"
    }
    cidr_blocks {
      cidr_block = "1.2.3.4/32"
      display_name = "redacted"
    }
    cidr_blocks {
      cidr_block = "1.2.3.4/32"
      display_name = "redacted"
    }
    cidr_blocks {
      cidr_block = "1.2.3.4/32"
      display_name = "redacted"
    }
    cidr_blocks {
      cidr_block = "1.2.3.4/32"
      display_name = "redacted"
    }
    cidr_blocks {
      cidr_block = "1.2.3.4/32"
      display_name = "redacted"
    }
  }

As mentioned in the terraform 0.12 upgrade guide, you can no longer use the cidr_blocks = [{ ... }] attribute format in your config files, you need to use the cidr_blocks { } block format.

This is, unfortunately, outside the control of the provider and is documented behavior, so I'm going to close this issue out, but if you have further issues or I've misunderstood what's going on here, please feel free to reply and I can take a look again.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings