google_dns_policy

A policy is a collection of DNS rules applied to one or more Virtual Private Cloud resources.

To get more information about Policy, see:

Open in Cloud Shell

Example Usage - Dns Policy Basic

resource "google_dns_policy" "example-policy" {
  name                      = "example-policy"
  enable_inbound_forwarding = true

  enable_logging = true

  alternative_name_server_config {
    target_name_servers {
      ipv4_address    = "172.16.1.10"
      forwarding_path = "private"
    }
    target_name_servers {
      ipv4_address = "172.16.1.20"
    }
  }

  networks {
    network_url = google_compute_network.network-1.id
  }
  networks {
    network_url = google_compute_network.network-2.id
  }
}

resource "google_compute_network" "network-1" {
  name                    = "network-1"
  auto_create_subnetworks = false
}

resource "google_compute_network" "network-2" {
  name                    = "network-2"
  auto_create_subnetworks = false
}

Argument Reference

The following arguments are supported:


The alternative_name_server_config block supports:

The target_name_servers block supports:

The networks block supports:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

Policy can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import Policy using one of the formats above. For example:

import {
  id = "projects/{{project}}/policies/{{name}}"
  to = google_dns_policy.default
}

When using the terraform import command, Policy can be imported using one of the formats above. For example:

$ terraform import google_dns_policy.default projects/{{project}}/policies/{{name}}
$ terraform import google_dns_policy.default {{project}}/{{name}}
$ terraform import google_dns_policy.default {{name}}

User Project Overrides

This resource supports User Project Overrides.