terraform-google-network icon indicating copy to clipboard operation
terraform-google-network copied to clipboard

Error while Creating a subnet

Open jhansinaidu opened this issue 3 years ago • 5 comments

TL;DR

image

Expected behavior

As there is an update in the subnet code for filter expression we should be able to enable the flow logs in GCP by setting the filter expression to false.

But receiving an error for purpose and role which I haven't noticed in the previous version with the same config.

Observed behavior

While referring the new version of the subnet (5.1.0) receiving and error for resource "google_compute_subnetwork" "subnetwork"

62: purpose = lookup(each.value, "purpose", null) An argument named "purpose" is not expected here.

63: role = lookup(each.value, "role", null) An argument named "role" is not expected here.

Terraform Configuration

module "subnets" {
  source  = "terraform-google-modules/network/google//modules/subnets"
  version = "5.1.0"

  project_id   = var.project_id
  network_name = var.network_name

  subnets = var.subnets

  #optional inputs
  secondary_ranges = var.secondary_ranges
}

This simple module is working fine, but while referring this module in different repo there is an issue

module "shared_vpc_subnets" {
  source = "*******"

  count        = var.subnet_inputs.create_new_subnets ? 1 : 0
  project_id   = lookup(var.subnet_inputs, "shared_vpc_project_id")
  network_name = lookup(var.subnet_inputs, "shared_vpc_network_name")

  subnets = lookup(var.subnet_inputs, "subnets")
  secondary_ranges = lookup(var.subnet_inputs, "secondary_subnet_ranges")
}

Terraform Version

terraform {
  required_version = ">= 0.13.0"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "<5.0,>= 2.12"
    }
  }

  provider_meta "google" {
    module_name = "blueprints/terraform/terraform-google-network:subnets/v5.1.0"
  }
}

Additional information

No response

jhansinaidu avatar Jun 08 '22 18:06 jhansinaidu

I am having the same issue. Why are purpose and role required?

terraform plan
╷
│ Error: Unsupported argument
│ 
│   on .terraform/modules/network/modules/subnets/main.tf line 60, in resource "google_compute_subnetwork" "subnetwork":
│   60:   purpose = lookup(each.value, "purpose", null)
│ 
│ An argument named "purpose" is not expected here.
╵
╷
│ Error: Unsupported argument
│ 
│   on .terraform/modules/network/modules/subnets/main.tf line 61, in resource "google_compute_subnetwork" "subnetwork":
│   61:   role    = lookup(each.value, "role", null)
│ 
│ An argument named "role" is not expected here.

dspeck1 avatar Jun 09 '22 19:06 dspeck1

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[bot] avatar Aug 08 '22 23:08 github-actions[bot]

@dspeck1 @jhansinaidu What version of the provider are you using?

bharathkkb avatar Aug 10 '22 22:08 bharathkkb

@bharathkkb terraform { required_version = ">= 0.13.0" required_providers { google = { source = "hashicorp/google" version = "<5.0,>= 2.12" } }

provider_meta "google" { module_name = "blueprints/terraform/terraform-google-network:subnets/v5.1.0" } }

jhansinaidu avatar Sep 06 '22 20:09 jhansinaidu

@jhansinaidu could you run a terraform version in your root config (the directory where you run tf apply) and paste the output? #377 should fix the min version for the module but since we allow >=2.12, you should be able to use a newer version in your root config.

bharathkkb avatar Sep 12 '22 18:09 bharathkkb