terraform-google-modules / terraform-google-cloud-nat

Creates and configures Cloud NAT
https://registry.terraform.io/modules/terraform-google-modules/cloud-nat/google
Apache License 2.0
81 stars 68 forks source link

var.nat_ip_allocate_option has to be set to false to be able to use MANUAL_ONLY #76

Closed Leweyy closed 1 year ago

Leweyy commented 2 years ago

TL;DR

var.nat_ip_allocate_option needing to be a bool doesnt make sense. It should be an enum of MANUAL_ONLY or AUTO_ONLY. if you set var.nat_ip_allocate_option to true the ternary operator takes the value of var.nat_ip_allocate_option which is true making it an invalid value for the compute_router_nat resource

Expected behavior

setting nat_ip_allocate_option to "MANUAL_ONLY" to work

Observed behavior

Errored invalid value as needed to be bool

Terraform Configuration

module "cloud_nat" {
  source     = "terraform-google-modules/cloud-nat/google"
  version    = "~> 2.2.1"

  name       = "${var.prefix}-nat-gateway"
  project_id = var.project_id

  region     = var.region
  router     = google_compute_router.router.name

  nat_ip_allocate_option = "MANUAL_ONLY"
  nat_ips = [ google_compute_address.nat_gw.address ]

  source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS"

  subnetworks = [ for subnet in local.private_subnets: {
    name = subnet.self_link
    source_ip_ranges_to_nat = [ subnet.ip_cidr_range ]
    secondary_ip_range_names = []
  }]

}

Terraform Version

Terraform v1.3.0

Additional information

No response

github-actions[bot] commented 1 year ago

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