Skip to content

Commit 3121c31

Browse files
Allow specifying global L7 ILB in dns_record_set routing policy (#8470) (#6084)
* Allow specifying global L7 ILB in dns_record_set routing policy * fix url_map default_service in docs * fix forwarding rule reference in rrset for cross-region test * don't specify region for globalL7ilb routing policy item * add backend subnet for FR IP address provisioning * pass backendSubnetName to cross-region L7 test case * remove google-beta req from test backend subnet * remove extra primary-backup examples * add globalL7ilb value to docs Signed-off-by: Modular Magician <[email protected]>
1 parent 8818831 commit 3121c31

File tree

4 files changed

+119
-101
lines changed

4 files changed

+119
-101
lines changed

.changelog/8470.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```release-note:enhancement
2+
dns: added `globalL7ilb` enum support to the `routing_policy.load_balancer_type` field in `google_dns_record_set`
3+
4+
```

google-beta/services/dns/resource_dns_record_set.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ var healthCheckedTargetSchema *schema.Resource = &schema.Resource{
260260
"load_balancer_type": {
261261
Type: schema.TypeString,
262262
Required: true,
263-
Description: `The type of load balancer. This value is case-sensitive. Possible values: ["regionalL4ilb", "regionalL7ilb]`,
264-
ValidateFunc: validation.StringInSlice([]string{"regionalL4ilb", "regionalL7ilb"}, false),
263+
Description: `The type of load balancer. This value is case-sensitive. Possible values: ["regionalL4ilb", "regionalL7ilb", "globalL7ilb"]`,
264+
ValidateFunc: validation.StringInSlice([]string{"regionalL4ilb", "regionalL7ilb", "globalL7ilb"}, false),
265265
},
266266
"ip_address": {
267267
Type: schema.TypeString,

google-beta/services/dns/resource_dns_record_set_test.go

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func TestAccDNSRecordSet_routingPolicy(t *testing.T) {
256256
t.Parallel()
257257

258258
networkName := fmt.Sprintf("tf-test-network-%s", acctest.RandString(t, 10))
259+
backendSubnetName := fmt.Sprintf("tf-test-backend-subnet-%s", acctest.RandString(t, 10))
259260
proxySubnetName := fmt.Sprintf("tf-test-proxy-subnet-%s", acctest.RandString(t, 10))
260261
httpHealthCheckName := fmt.Sprintf("tf-test-http-health-check-%s", acctest.RandString(t, 10))
261262
backendName := fmt.Sprintf("tf-test-backend-%s", acctest.RandString(t, 10))
@@ -304,6 +305,15 @@ func TestAccDNSRecordSet_routingPolicy(t *testing.T) {
304305
ImportState: true,
305306
ImportStateVerify: true,
306307
},
308+
{
309+
Config: testAccDnsRecordSet_routingPolicyCrossRegionL7PrimaryBackup(networkName, backendSubnetName, proxySubnetName, httpHealthCheckName, backendName, urlMapName, httpProxyName, forwardingRuleName, zoneName, 300),
310+
},
311+
{
312+
ResourceName: "google_dns_record_set.foobar",
313+
ImportStateId: fmt.Sprintf("%s/%s/test-record.%s.hashicorptest.com./A", envvar.GetTestProjectFromEnv(), zoneName, zoneName),
314+
ImportState: true,
315+
ImportStateVerify: true,
316+
},
307317
},
308318
})
309319
}
@@ -828,6 +838,108 @@ resource "google_dns_record_set" "foobar" {
828838
`, networkName, proxySubnetName, healthCheckName, backendName, urlMapName, httpProxyName, forwardingRuleName, zoneName, zoneName, zoneName, ttl)
829839
}
830840

841+
func testAccDnsRecordSet_routingPolicyCrossRegionL7PrimaryBackup(networkName, backendSubnetName, proxySubnetName, healthCheckName, backendName, urlMapName, httpProxyName, forwardingRuleName, zoneName string, ttl int) string {
842+
return fmt.Sprintf(`
843+
resource "google_compute_network" "default" {
844+
name = "%s"
845+
}
846+
847+
resource "google_compute_subnetwork" "backend_subnet" {
848+
name = "%s"
849+
ip_cidr_range = "10.0.1.0/24"
850+
region = "us-central1"
851+
network = google_compute_network.default.id
852+
}
853+
854+
resource "google_compute_subnetwork" "proxy_subnet" {
855+
name = "%s"
856+
ip_cidr_range = "10.100.0.0/24"
857+
region = "us-central1"
858+
purpose = "GLOBAL_MANAGED_PROXY"
859+
role = "ACTIVE"
860+
network = google_compute_network.default.id
861+
}
862+
863+
resource "google_compute_health_check" "health_check" {
864+
name = "%s"
865+
866+
http_health_check {
867+
port = 80
868+
}
869+
}
870+
871+
resource "google_compute_backend_service" "backend" {
872+
name = "%s"
873+
load_balancing_scheme = "INTERNAL_MANAGED"
874+
protocol = "HTTP"
875+
health_checks = [google_compute_health_check.health_check.id]
876+
}
877+
878+
resource "google_compute_url_map" "url_map" {
879+
name = "%s"
880+
default_service = google_compute_backend_service.backend.id
881+
}
882+
883+
resource "google_compute_target_http_proxy" "http_proxy" {
884+
name = "%s"
885+
url_map = google_compute_url_map.url_map.id
886+
}
887+
888+
resource "google_compute_global_forwarding_rule" "default" {
889+
name = "%s"
890+
depends_on = [google_compute_subnetwork.proxy_subnet]
891+
load_balancing_scheme = "INTERNAL_MANAGED"
892+
target = google_compute_target_http_proxy.http_proxy.id
893+
port_range = "80"
894+
network = google_compute_network.default.name
895+
subnetwork = google_compute_subnetwork.backend_subnet.name
896+
ip_protocol = "TCP"
897+
}
898+
899+
resource "google_dns_managed_zone" "parent-zone" {
900+
name = "%s"
901+
dns_name = "%s.hashicorptest.com."
902+
description = "Test Description"
903+
visibility = "private"
904+
}
905+
906+
resource "google_dns_record_set" "foobar" {
907+
managed_zone = google_dns_managed_zone.parent-zone.name
908+
name = "test-record.%s.hashicorptest.com."
909+
type = "A"
910+
ttl = %d
911+
912+
routing_policy {
913+
primary_backup {
914+
trickle_ratio = 0.1
915+
enable_geo_fencing_for_backups = true
916+
917+
primary {
918+
internal_load_balancers {
919+
load_balancer_type = "globalL7ilb"
920+
ip_address = google_compute_global_forwarding_rule.default.ip_address
921+
port = "80"
922+
ip_protocol = "tcp"
923+
network_url = google_compute_network.default.id
924+
project = google_compute_global_forwarding_rule.default.project
925+
}
926+
}
927+
928+
backup_geo {
929+
location = "us-west1"
930+
rrdatas = ["1.2.3.4"]
931+
}
932+
933+
backup_geo {
934+
location = "asia-east1"
935+
rrdatas = ["5.6.7.8"]
936+
}
937+
}
938+
}
939+
}
940+
`, networkName, backendSubnetName, proxySubnetName, healthCheckName, backendName, urlMapName, httpProxyName, forwardingRuleName, zoneName, zoneName, zoneName, ttl)
941+
}
942+
831943
func testAccDnsRecordSet_interpolated(zoneName string) string {
832944
return fmt.Sprintf(`
833945
resource "google_dns_managed_zone" "parent-zone" {

website/docs/r/dns_record_set.html.markdown

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -241,104 +241,6 @@ resource "google_compute_network" "prod" {
241241
}
242242
```
243243

244-
#### Primary-Backup with a regional L7 ILB
245-
246-
```hcl
247-
resource "google_dns_record_set" "a" {
248-
name = "backend.${google_dns_managed_zone.prod.dns_name}"
249-
managed_zone = google_dns_managed_zone.prod.name
250-
type = "A"
251-
ttl = 300
252-
253-
routing_policy {
254-
primary_backup {
255-
trickle_ratio = 0.1
256-
257-
primary {
258-
internal_load_balancers {
259-
load_balancer_type = "regionalL7ilb"
260-
ip_address = google_compute_forwarding_rule.prod.ip_address
261-
port = "80"
262-
ip_protocol = "tcp"
263-
network_url = google_compute_network.prod.id
264-
project = google_compute_forwarding_rule.prod.project
265-
region = google_compute_forwarding_rule.prod.region
266-
}
267-
}
268-
269-
backup_geo {
270-
location = "asia-east1"
271-
rrdatas = ["10.128.1.1"]
272-
}
273-
274-
backup_geo {
275-
location = "us-west1"
276-
rrdatas = ["10.130.1.1"]
277-
}
278-
}
279-
}
280-
}
281-
282-
resource "google_dns_managed_zone" "prod" {
283-
name = "prod-zone"
284-
dns_name = "prod.mydomain.com."
285-
}
286-
287-
resource "google_compute_forwarding_rule" "prod" {
288-
name = "prod-ilb"
289-
region = "us-central1"
290-
depends_on = [google_compute_subnetwork.prod_proxy]
291-
load_balancing_scheme = "INTERNAL_MANAGED"
292-
target = google_compute_region_target_http_proxy.prod.id
293-
port_range = "80"
294-
allow_global_access = true
295-
network = google_compute_network.prod.name
296-
ip_protocol = "TCP"
297-
}
298-
299-
resource "google_compute_region_target_http_proxy" "prod" {
300-
name = "prod-http-proxy"
301-
region = "us-central1"
302-
url_map = google_compute_region_url_map.prod.id
303-
}
304-
305-
resource "google_compute_region_url_map" "prod" {
306-
name = "prod-url-map"
307-
region = "us-central1"
308-
default_service = google_compute_region_backend_service.prod.id
309-
}
310-
311-
resource "google_compute_region_backend_service" "prod" {
312-
name = "prod-backend"
313-
region = "us-central1"
314-
load_balancing_scheme = "INTERNAL_MANAGED"
315-
protocol = "HTTP"
316-
health_checks = [google_compute_region_health_check.prod.id]
317-
}
318-
319-
resource "google_compute_region_health_check" "prod" {
320-
name = "prod-http-health-check"
321-
region = "us-central1"
322-
323-
http_health_check {
324-
port = 80
325-
}
326-
}
327-
328-
resource "google_compute_subnetwork" "prod_proxy" {
329-
name = "prod-proxy-subnet"
330-
ip_cidr_range = "10.100.0.0/24"
331-
region = "us-central1"
332-
purpose = "INTERNAL_HTTPS_LOAD_BALANCER"
333-
role = "ACTIVE"
334-
network = google_compute_network.prod.id
335-
}
336-
337-
resource "google_compute_network" "prod" {
338-
name = "prod-network"
339-
}
340-
```
341-
342244
## Argument Reference
343245

344246
The following arguments are supported:
@@ -414,7 +316,7 @@ The following arguments are supported:
414316

415317
<a name="nested_internal_load_balancers"></a>The `internal_load_balancers` block supports:
416318

417-
* `load_balancer_type` - (Required) The type of load balancer. This value is case-sensitive. Possible values: ["regionalL4ilb", "regionalL7ilb"]
319+
* `load_balancer_type` - (Required) The type of load balancer. This value is case-sensitive. Possible values: ["regionalL4ilb", "regionalL7ilb", "globalL7ilb"]
418320

419321
* `ip_address` - (Required) The frontend IP address of the load balancer.
420322

0 commit comments

Comments
 (0)