# DNSPolicy

| **Property** | **Value** |
|---|---|
| Google Cloud Service Name | Cloud DNS |
| Google Cloud Service Documentation | [/dns/docs/](https://docs.cloud.google.com/dns/docs) |
| Google Cloud REST Resource Name | v1beta2.policy |
| Google Cloud REST Resource Documentation | [/dns/docs/reference/rest/v1beta2/policies](https://docs.cloud.google.com/dns/docs/reference/v1beta2/policies) |
| Config Connector Resource Short Names | dnspolicy gcpdnspolicies gcpdnspolicy |
| Config Connector Service Name | dns.googleapis.com |
| Config Connector Resource Fully Qualified Name | dnspolicies.dns.cnrm.cloud.google.com |
| Can Be Referenced by IAMPolicy/IAMPolicyMember | No |
| Config Connector Default Average Reconcile Interval In Seconds | 600 |

## Custom Resource Definition Properties

### Annotations

| Fields ||
|---|---|
| `cnrm.cloud.google.com/project-id` |

### Spec

#### Schema

    alternativeNameServerConfig:
      targetNameServers:
      - forwardingPath: string
        ipv4Address: string
    description: string
    enableInboundForwarding: boolean
    enableLogging: boolean
    networks:
    - networkRef:
        external: string
        name: string
        namespace: string
    resourceID: string

| Fields ||
|---|---|
| `alternativeNameServerConfig` *Optional* | `object` 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. |
| `alternativeNameServerConfig.targetNameServers` *Required\** | `list (object)` 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. |
| `alternativeNameServerConfig.targetNameServers[]` *Required\** | `object` <br /> |
| `alternativeNameServerConfig.targetNameServers[].forwardingPath` *Optional* | `string` 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: \["default", "private"\]. |
| `alternativeNameServerConfig.targetNameServers[].ipv4Address` *Required\** | `string` IPv4 address to forward to. |
| `description` *Optional* | `string` A textual description field. Defaults to 'Managed by Config Connector'. |
| `enableInboundForwarding` *Optional* | `boolean` 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. |
| `enableLogging` *Optional* | `boolean` Controls whether logging is enabled for the networks bound to this policy. Defaults to no logging if not set. |
| `networks` *Optional* | `list (object)` List of network names specifying networks to which this policy is applied. |
| `networks[]` *Optional* | `object` <br /> |
| `networks[].networkRef` *Required\** | `object` VPC network to bind to. |
| `networks[].networkRef.external` *Optional* | `string` A reference to an externally managed ComputeNetwork resource. Should be in the format "projects/{{projectID}}/global/networks/{{networkID}}". |
| `networks[].networkRef.name` *Optional* | `string` The name of a ComputeNetwork resource. |
| `networks[].networkRef.namespace` *Optional* | `string` The namespace of a ComputeNetwork resource. |
| `resourceID` *Optional* | `string` Immutable. Optional. The name of the resource. Used for creation and acquisition. When unset, the value of \`metadata.name\` is used as the default. |

\* Field is required when parent field is specified

### Status

#### Schema

    conditions:
    - lastTransitionTime: string
      message: string
      reason: string
      status: string
      type: string
    observedGeneration: integer

| Fields ||
|---|---|
| `conditions` | `list (object)` Conditions represent the latest available observations of the DNSPolicy's current state. |
| `conditions[]` | `object` <br /> |
| `conditions[].lastTransitionTime` | `string` Last time the condition transitioned from one status to another. |
| `conditions[].message` | `string` Human-readable message indicating details about last transition. |
| `conditions[].reason` | `string` Unique, one-word, CamelCase reason for the condition's last transition. |
| `conditions[].status` | `string` Status is the status of the condition. Can be True, False, Unknown. |
| `conditions[].type` | `string` Type is the type of the condition. |
| `observedGeneration` | `integer` ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. |

## Sample YAML(s)

### Typical Use Case

    # Copyright 2020 Google LLC
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.

    apiVersion: dns.cnrm.cloud.google.com/v1beta1
    kind: DNSPolicy
    metadata:
      name: dnspolicy-sample
    spec:
      alternativeNameServerConfig:
        targetNameServers:
          - ipv4Address: "104.132.166.92"
      description: "Example DNS policy"
      enableInboundForwarding: true
      enableLogging: true
      networks:
        - networkRef:
            name: dnspolicy-dep
    ---
    apiVersion: compute.cnrm.cloud.google.com/v1beta1
    kind: ComputeNetwork
    metadata:
      name: dnspolicy-dep
    spec:
      autoCreateSubnetworks: false

> [!NOTE]
> **Note:** If you have any trouble with instantiating the resource, refer to [Troubleshoot Config Connector](https://docs.cloud.google.com/config-connector/docs/troubleshooting).