@@ -348,6 +348,9 @@ func TestAccDNSRecordSet_routingPolicy(t *testing.T) {
348348 ImportState : true ,
349349 ImportStateVerify : true ,
350350 },
351+ {
352+ Config : testAccDnsRecordSet_routingPolicyRegionalL7XLBPrimaryBackup (networkName , proxySubnetName , httpHealthCheckName , backendName , urlMapName , httpProxyName , forwardingRuleName , zoneName , 300 ),
353+ },
351354 },
352355 })
353356}
@@ -1315,3 +1318,207 @@ resource "google_dns_record_set" "foobar" {
13151318}
13161319` , zoneName , zoneName , zoneName )
13171320}
1321+
1322+ func testAccDnsRecordSet_routingPolicyRegionalL7XLBPrimaryBackup (networkName , proxySubnetName , healthCheckName , backendName , urlMapName , httpProxyName , forwardingRuleName , zoneName string , ttl int ) string {
1323+ return fmt .Sprintf (`
1324+ resource "google_compute_network" "default" {
1325+ name = "%s"
1326+ }
1327+
1328+ resource "google_compute_subnetwork" "proxy_subnet" {
1329+ name = "%s"
1330+ ip_cidr_range = "10.100.0.0/24"
1331+ region = "us-central1"
1332+ purpose = "REGIONAL_MANAGED_PROXY"
1333+ role = "ACTIVE"
1334+ network = google_compute_network.default.id
1335+ }
1336+
1337+ resource "google_compute_subnetwork" "backup_proxy_subnet" {
1338+ name = "${google_compute_subnetwork.proxy_subnet.name}-usw1"
1339+ ip_cidr_range = "10.100.1.0/24"
1340+ region = "us-west1"
1341+ purpose = "REGIONAL_MANAGED_PROXY"
1342+ role = "ACTIVE"
1343+ network = google_compute_network.default.id
1344+ }
1345+
1346+ resource "google_compute_region_health_check" "health_check" {
1347+ name = "%s"
1348+ region = "us-central1"
1349+
1350+ http_health_check {
1351+ port = 80
1352+ }
1353+ }
1354+
1355+ resource "google_compute_region_health_check" "backup_health_check" {
1356+ name = "${google_compute_region_health_check.health_check.name}-usw1"
1357+ region = "us-west1"
1358+
1359+ http_health_check {
1360+ port = 80
1361+ }
1362+ }
1363+
1364+ resource "google_compute_region_backend_service" "backend" {
1365+ name = "%s"
1366+ region = "us-central1"
1367+ load_balancing_scheme = "EXTERNAL_MANAGED"
1368+ protocol = "HTTP"
1369+ health_checks = [google_compute_region_health_check.health_check.id]
1370+ }
1371+
1372+ resource "google_compute_region_backend_service" "backup_backend" {
1373+ name = "${google_compute_region_backend_service.backend.name}-usw1"
1374+ region = "us-west1"
1375+ load_balancing_scheme = "EXTERNAL_MANAGED"
1376+ protocol = "HTTP"
1377+ health_checks = [google_compute_region_health_check.backup_health_check.id]
1378+ }
1379+
1380+ resource "google_compute_region_url_map" "url_map" {
1381+ name = "%s"
1382+ region = "us-central1"
1383+ default_service = google_compute_region_backend_service.backend.id
1384+ }
1385+
1386+ resource "google_compute_region_url_map" "backup_url_map" {
1387+ name = "${google_compute_region_url_map.url_map.name}-usw1"
1388+ region = "us-west1"
1389+ default_service = google_compute_region_backend_service.backup_backend.id
1390+ }
1391+
1392+ resource "google_compute_region_target_http_proxy" "http_proxy" {
1393+ name = "%s"
1394+ region = "us-central1"
1395+ url_map = google_compute_region_url_map.url_map.id
1396+ }
1397+
1398+ resource "google_compute_region_target_http_proxy" "backup_http_proxy" {
1399+ name = "${google_compute_region_target_http_proxy.http_proxy.name}-usw1"
1400+ region = "us-west1"
1401+ url_map = google_compute_region_url_map.backup_url_map.id
1402+ }
1403+
1404+ resource "google_compute_forwarding_rule" "default" {
1405+ name = "%s"
1406+ region = "us-central1"
1407+ depends_on = [google_compute_subnetwork.proxy_subnet]
1408+ load_balancing_scheme = "EXTERNAL_MANAGED"
1409+ target = google_compute_region_target_http_proxy.http_proxy.id
1410+ port_range = "80"
1411+ network = google_compute_network.default.name
1412+ ip_protocol = "TCP"
1413+ }
1414+
1415+ resource "google_compute_forwarding_rule" "backup" {
1416+ name = "${google_compute_forwarding_rule.default.name}-usw1"
1417+ region = "us-west1"
1418+ depends_on = [google_compute_subnetwork.backup_proxy_subnet]
1419+ load_balancing_scheme = "EXTERNAL_MANAGED"
1420+ target = google_compute_region_target_http_proxy.backup_http_proxy.id
1421+ port_range = "80"
1422+ network = google_compute_network.default.name
1423+ ip_protocol = "TCP"
1424+ }
1425+
1426+ resource "google_compute_health_check" "health_check" {
1427+ name = "${google_compute_region_health_check.health_check.name}-dns"
1428+
1429+ timeout_sec = 5
1430+ check_interval_sec = 30
1431+ healthy_threshold = 4
1432+ unhealthy_threshold = 5
1433+
1434+ http_health_check {
1435+ port = 80
1436+ }
1437+
1438+ source_regions = ["us-central1", "us-west1", "us-east1"]
1439+ }
1440+
1441+ resource "google_dns_managed_zone" "parent-zone" {
1442+ name = "%s"
1443+ dns_name = "%s.hashicorptest.com."
1444+ description = "Test Description"
1445+ visibility = "public"
1446+ }
1447+
1448+ resource "google_dns_record_set" "failover" {
1449+ managed_zone = google_dns_managed_zone.parent-zone.name
1450+ name = "failover-test-record.%s.hashicorptest.com."
1451+ type = "A"
1452+ ttl = %d
1453+
1454+ routing_policy {
1455+ health_check = google_compute_health_check.health_check.id
1456+ primary_backup {
1457+ trickle_ratio = 0.1
1458+ enable_geo_fencing_for_backups = true
1459+
1460+ primary {
1461+ external_endpoints = [google_compute_forwarding_rule.default.ip_address]
1462+ }
1463+
1464+ backup_geo {
1465+ location = "us-west1"
1466+ health_checked_targets {
1467+ external_endpoints = [google_compute_forwarding_rule.backup.ip_address]
1468+ }
1469+ }
1470+ }
1471+ }
1472+ }
1473+
1474+ resource "google_dns_record_set" "wrr" {
1475+ managed_zone = google_dns_managed_zone.parent-zone.name
1476+ name = replace(google_dns_record_set.failover.name, "failover-test-record", "wrr-test-record")
1477+ type = "A"
1478+ ttl = google_dns_record_set.failover.ttl
1479+
1480+ routing_policy {
1481+ health_check = google_compute_health_check.health_check.id
1482+ wrr {
1483+ weight = 0.8
1484+ rrdatas = [google_compute_forwarding_rule.default.ip_address]
1485+ health_checked_targets {
1486+ external_endpoints = [google_compute_forwarding_rule.default.ip_address]
1487+ }
1488+ }
1489+ wrr {
1490+ weight = 0.2
1491+ rrdatas = [google_compute_forwarding_rule.backup.ip_address]
1492+ health_checked_targets {
1493+ external_endpoints = [google_compute_forwarding_rule.backup.ip_address]
1494+ }
1495+ }
1496+ }
1497+ }
1498+
1499+ resource "google_dns_record_set" "geo" {
1500+ managed_zone = google_dns_managed_zone.parent-zone.name
1501+ name = replace(google_dns_record_set.failover.name, "failover-test-record", "geo-test-record")
1502+ type = "A"
1503+ ttl = google_dns_record_set.failover.ttl
1504+
1505+ routing_policy {
1506+ health_check = google_compute_health_check.health_check.id
1507+ geo {
1508+ location = "us-central1"
1509+ rrdatas = [google_compute_forwarding_rule.default.ip_address]
1510+ health_checked_targets {
1511+ external_endpoints = [google_compute_forwarding_rule.default.ip_address]
1512+ }
1513+ }
1514+ geo {
1515+ location = "us-west1"
1516+ rrdatas = [google_compute_forwarding_rule.backup.ip_address]
1517+ health_checked_targets {
1518+ external_endpoints = [google_compute_forwarding_rule.backup.ip_address]
1519+ }
1520+ }
1521+ }
1522+ }
1523+ ` , networkName , proxySubnetName , healthCheckName , backendName , urlMapName , httpProxyName , forwardingRuleName , zoneName , zoneName , zoneName , ttl )
1524+ }
0 commit comments