| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Cloud DNS" |
| description: |- |
| A policy is a collection of DNS rules applied to one or more Virtual |
| Private Cloud resources. |
| --- |
| |
| # 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: |
| |
| * [API documentation](https://cloud.google.com/dns/docs/reference/v1beta2/policies) |
| * How-to Guides |
| * [Using DNS server policies](https://cloud.google.com/dns/zones/#using-dns-server-policies) |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=dns_policy_basic&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Dns Policy Basic |
| |
| |
| ```hcl |
| 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: |
| |
| |
| * `name` - |
| (Required) |
| User assigned name for this policy. |
| |
| |
| - - - |
| |
| |
| * `alternative_name_server_config` - |
| (Optional) |
| Sets an alternative name server for the associated networks. |
| When specified, all DNS queries are forwarded to a name server that you choose. |
| Names such as .internal are not available when an alternative name server is specified. |
| Structure is [documented below](#nested_alternative_name_server_config). |
| |
| * `description` - |
| (Optional) |
| A textual description field. Defaults to 'Managed by Terraform'. |
| |
| * `enable_inbound_forwarding` - |
| (Optional) |
| Allows networks bound to this policy to receive DNS queries sent |
| by VMs or applications over VPN connections. When enabled, a |
| virtual IP address will be allocated from each of the sub-networks |
| that are bound to this policy. |
| |
| * `enable_logging` - |
| (Optional) |
| Controls whether logging is enabled for the networks bound to this policy. |
| Defaults to no logging if not set. |
| |
| * `networks` - |
| (Optional) |
| List of network names specifying networks to which this policy is applied. |
| Structure is [documented below](#nested_networks). |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| |
| <a name="nested_alternative_name_server_config"></a>The `alternative_name_server_config` block supports: |
| |
| * `target_name_servers` - |
| (Required) |
| Sets an alternative name server for the associated networks. When specified, |
| all DNS queries are forwarded to a name server that you choose. Names such as .internal |
| are not available when an alternative name server is specified. |
| Structure is [documented below](#nested_target_name_servers). |
| |
| |
| <a name="nested_target_name_servers"></a>The `target_name_servers` block supports: |
| |
| * `ipv4_address` - |
| (Required) |
| IPv4 address to forward to. |
| |
| * `forwarding_path` - |
| (Optional) |
| Forwarding path for this TargetNameServer. If unset or `default` Cloud DNS will make forwarding |
| decision based on address ranges, i.e. RFC1918 addresses go to the VPC, Non-RFC1918 addresses go |
| to the Internet. When set to `private`, Cloud DNS will always send queries through VPC for this target |
| Possible values are: `default`, `private`. |
| |
| <a name="nested_networks"></a>The `networks` block supports: |
| |
| * `network_url` - |
| (Required) |
| The id or fully qualified URL of the VPC network to forward queries to. |
| This should be formatted like `projects/{project}/global/networks/{network}` or |
| `https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}` |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/policies/{{name}}` |
| |
| |
| ## Timeouts |
| |
| This resource provides the following |
| [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `update` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| Policy can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/policies/{{name}}` |
| * `{{project}}/{{name}}` |
| * `{{name}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Policy using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/policies/{{name}}" |
| to = google_dns_policy.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), 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](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |