hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.33k stars 1.73k forks source link

Unable to create google_dns_record_set with failover #19250

Open nicku1 opened 2 months ago

nicku1 commented 2 months ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.9.5 on linux_amd64

Affected Resource(s)

google_dns_record_set

Terraform Configuration

resource "google_dns_record_set" "a" {
  name         = "backend.${google_dns_managed_zone.prod.dns_name}"
  managed_zone = google_dns_managed_zone.prod.name
  type         = "A"
  ttl          = 300
  project = var.project

  routing_policy {
    primary_backup {
      trickle_ratio = 0.1

      primary {
        internal_load_balancers {
          load_balancer_type = "regionalL4ilb"
          ip_address         = google_compute_forwarding_rule.prod.ip_address
          port               = "80"
          ip_protocol        = "tcp"
          network_url        = google_compute_network.prod.id
          project            = google_compute_forwarding_rule.prod.project
          region             = google_compute_forwarding_rule.prod.region
        }
      }

      backup_geo {
        location = "asia-east1"
        rrdatas  = ["10.128.1.1"]
      }

      backup_geo {
        location = "us-west1"
        rrdatas  = ["10.130.1.1"]
      }
    }
  }
}

resource "google_dns_managed_zone" "prod" {
  name     = "prod-zone"
  dns_name = "prod.nicu.pl."
  project = var.project
}

resource "google_compute_forwarding_rule" "prod" {
  name   = "prod-ilb"
  region = "us-central1"
  project = var.project

  load_balancing_scheme = "INTERNAL"
  backend_service       = google_compute_region_backend_service.prod.id
  all_ports             = true
  network               = google_compute_network.prod.name
  allow_global_access   = true
}

resource "google_compute_region_backend_service" "prod" {
  name   = "prod-backend"
  region = "us-central1"
  project = var.project
}

resource "google_compute_network" "prod" {
  name = "prod-network"
  project = var.project
}

Debug Output

https://gist.github.com/nicku1/d911aede54ac832e0552d798e17f64af

Expected Behavior

Example provided in https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/dns_record_set should end up with successful provisioning of DNS rule.

Actual Behavior

Error message:

β•·
β”‚ Error: Error creating DNS RecordSet: googleapi: Error 400: Routing policies referencing internal load balancers cannot be added to public zones, internalLoadBalancerDisallowedInPublicZone
β”‚ 
β”‚   with module.network.google_dns_record_set.a,
β”‚   on network/dns_test.tf line 1, in resource "google_dns_record_set" "a":
β”‚    1: resource "google_dns_record_set" "a" {
β”‚ 
β•΅

Steps to reproduce

  1. terraform apply

Important Factoids

I'm using default application authentication instead of service account.

References

https://github.com/hashicorp/terraform-provider-google/issues/13269

b/363269342

ggtisc commented 2 months ago

Confirmed issue!

The error appears when using the failover terraform registry example.