# ComputeFirewallPolicyRule

| **Property** | **Value** |
|---|---|
| Google Cloud Service Name | Compute Engine |
| Google Cloud Service Documentation | [/compute/docs/](https://docs.cloud.google.com/compute/docs) |
| Google Cloud REST Resource Name | v1.firewallPolicies |
| Google Cloud REST Resource Documentation | <https://docs.cloud.google.com/compute/docs/reference/rest/v1/firewallPolicies> |
| Config Connector Resource Short Names | computefirewallpolicyrule gcpcomputefirewallpolicyrule gcpcomputefirewallpolicyrules |
| Config Connector Service Name | compute.googleapis.com |
| Config Connector Resource Fully Qualified Name | computefirewallpolicyrules.compute.cnrm.cloud.google.com |
| Can Be Referenced by IAMPolicy/IAMPolicyMember | No |
| Config Connector Default Average Reconcile Interval In Seconds | 600 |

## Custom Resource Definition Properties

### Spec

#### Schema

    action: string
    description: string
    direction: string
    disabled: boolean
    enableLogging: boolean
    firewallPolicyRef:
      external: string
      name: string
      namespace: string
    match:
      destAddressGroups:
      - string
      destFqdns:
      - string
      destIPRanges:
      - string
      destRegionCodes:
      - string
      destThreatIntelligences:
      - string
      layer4Configs:
      - ipProtocol: string
        ports:
        - string
      srcAddressGroups:
      - string
      srcFqdns:
      - string
      srcIPRanges:
      - string
      srcRegionCodes:
      - string
      srcThreatIntelligences:
      - string
    priority: integer
    targetResources:
    - external: string
      name: string
      namespace: string
    targetServiceAccounts:
    - external: string
      name: string
      namespace: string

| Fields ||
|---|---|
| `action` *Required\** | `string` The Action to perform when the client connection triggers the rule. Valid actions are "allow", "deny" and "goto_next". |
| `description` *Optional* | `string` An optional description for this resource. |
| `direction` *Required\** | `string` The direction in which this rule applies. Possible values: INGRESS, EGRESS |
| `disabled` *Optional* | `boolean` Denotes whether the firewall policy rule is disabled. When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist. If this is unspecified, the firewall policy rule will be enabled. |
| `enableLogging` *Optional* | `boolean` Denotes whether to enable logging for a particular rule. If logging is enabled, logs will be exported to the configured export destination in Stackdriver. Logs may be exported to BigQuery or Pub/Sub. Note: you cannot enable logging on "goto_next" rules. |
| `firewallPolicyRef` *Required\** | `object` Immutable. |
| `firewallPolicyRef.external` *Optional* | `string` A reference to an externally managed ComputeFirewallPolicy resource. Should be in the format "locations/global/firewallPolicies/{{firewallPolicyID}}". |
| `firewallPolicyRef.name` *Optional* | `string` The name of a ComputeFirewallPolicy resource. |
| `firewallPolicyRef.namespace` *Optional* | `string` The namespace of a ComputeFirewallPolicy resource. |
| `match` *Required\** | `object` A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced. |
| `match.destAddressGroups` *Optional* | `list (string)` Address groups which should be matched against the traffic destination. Maximum number of destination address groups is 10. Destination address groups is only supported in Egress rules. |
| `match.destAddressGroups[]` *Optional* | `string` <br /> |
| `match.destFqdns` *Optional* | `list (string)` Domain names that will be used to match against the resolved domain name of destination of traffic. Can only be specified if DIRECTION is egress. |
| `match.destFqdns[]` *Optional* | `string` <br /> |
| `match.destIPRanges` *Optional* | `list (string)` CIDR IP address range. Maximum number of destination CIDR IP ranges allowed is 256. |
| `match.destIPRanges[]` *Optional* | `string` <br /> |
| `match.destRegionCodes` *Optional* | `list (string)` The Unicode country codes whose IP addresses will be used to match against the source of traffic. Can only be specified if DIRECTION is egress. |
| `match.destRegionCodes[]` *Optional* | `string` <br /> |
| `match.destThreatIntelligences` *Optional* | `list (string)` Name of the Google Cloud Threat Intelligence list. |
| `match.destThreatIntelligences[]` *Optional* | `string` <br /> |
| `match.layer4Configs` *Required\** | `list (object)` Pairs of IP protocols and ports that the rule should match. |
| `match.layer4Configs[]` *Required\** | `object` <br /> |
| `match.layer4Configs[].ipProtocol` *Required\** | `string` The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule. This value can either be one of the following well known protocol strings (\`tcp\`, \`udp\`, \`icmp\`, \`esp\`, \`ah\`, \`ipip\`, \`sctp\`), or the IP protocol number. |
| `match.layer4Configs[].ports` *Optional* | `list (string)` An optional list of ports to which this rule applies. This field is only applicable for UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, this rule applies to connections through any port. Example inputs include: \`\`. |
| `match.layer4Configs[].ports[]` *Optional* | `string` <br /> |
| `match.srcAddressGroups` *Optional* | `list (string)` Address groups which should be matched against the traffic source. Maximum number of source address groups is 10. Source address groups is only supported in Ingress rules. |
| `match.srcAddressGroups[]` *Optional* | `string` <br /> |
| `match.srcFqdns` *Optional* | `list (string)` Domain names that will be used to match against the resolved domain name of source of traffic. Can only be specified if DIRECTION is ingress. |
| `match.srcFqdns[]` *Optional* | `string` <br /> |
| `match.srcIPRanges` *Optional* | `list (string)` CIDR IP address range. Maximum number of source CIDR IP ranges allowed is 256. |
| `match.srcIPRanges[]` *Optional* | `string` <br /> |
| `match.srcRegionCodes` *Optional* | `list (string)` The Unicode country codes whose IP addresses will be used to match against the source of traffic. Can only be specified if DIRECTION is ingress. |
| `match.srcRegionCodes[]` *Optional* | `string` <br /> |
| `match.srcThreatIntelligences` *Optional* | `list (string)` Name of the Google Cloud Threat Intelligence list. |
| `match.srcThreatIntelligences[]` *Optional* | `string` <br /> |
| `priority` *Required\** | `integer` Immutable. An integer indicating the priority of a rule in the list. The priority must be a positive value between 0 and 2147483647. Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest prority. |
| `targetResources` *Optional* | `list (object)` <br /> |
| `targetResources[]` *Optional* | `object` ComputeNetworkRef is a reference to a Google Cloud ComputeNetwork. |
| `targetResources[].external` *Optional* | `string` A reference to an externally managed ComputeNetwork resource. Should be in the format "projects/{{projectID}}/global/networks/{{networkID}}". |
| `targetResources[].name` *Optional* | `string` The name of a ComputeNetwork resource. |
| `targetResources[].namespace` *Optional* | `string` The namespace of a ComputeNetwork resource. |
| `targetServiceAccounts` *Optional* | `list (object)` <br /> |
| `targetServiceAccounts[]` *Optional* | `object` <br /> |
| `targetServiceAccounts[].external` *Optional* | `string` The \`email\` field of an \`IAMServiceAccount\` resource. |
| `targetServiceAccounts[].name` *Optional* | `string` Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names |
| `targetServiceAccounts[].namespace` *Optional* | `string` Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ |

\* Field is required when parent field is specified

### Status

#### Schema

    conditions:
    - lastTransitionTime: string
      message: string
      reason: string
      status: string
      type: string
    externalRef: string
    kind: string
    observedGeneration: integer
    ruleTupleCount: integer

| Fields ||
|---|---|
| `conditions` | `list (object)` Conditions represent the latest available observations of the object'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. |
| `externalRef` | `string` A unique Config Connector specifier for the resource in Google Cloud. |
| `kind` | `string` Type of the resource. Always \`compute#firewallPolicyRule\` for firewall policy rules |
| `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. |
| `ruleTupleCount` | `integer` Calculation of the complexity of a single firewall policy rule. |

## 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: compute.cnrm.cloud.google.com/v1beta1
    kind: ComputeFirewallPolicyRule
    metadata:
      name: firewallpolicyrule-sample
    spec:
      action: "deny"
      description: "A Firewall Policy Rule"
      direction: "INGRESS"
      disabled: false
      enableLogging: false
      firewallPolicyRef:
        name: firewallpolicyrule-dep
      match:
        layer4Configs:
        - ipProtocol: "tcp"
        srcIPRanges:
        - "10.100.0.1/32"
      priority: 9000
      targetResources:
        - name: firewallpolicyrule-dep
      targetServiceAccounts:
        - name: firewallpolicyrule-dep
    ---
    apiVersion: compute.cnrm.cloud.google.com/v1beta1
    kind: ComputeFirewallPolicy
    metadata:
      name: firewallpolicyrule-dep
    spec:
      organizationRef:
        # Replace "${ORG_ID?}" with the numeric ID for your organization
        external: "organizations/${ORG_ID?}"
      # ComputeFirewallPolicy shortNames must be unique in the organization in
      # which the firewall policy is created
      shortName: ${PROJECT_ID?}-short
      description: "A basic organization firewall policy"
    ---
    apiVersion: compute.cnrm.cloud.google.com/v1beta1
    kind: ComputeNetwork
    metadata:
      name: firewallpolicyrule-dep
    spec:
      routingMode: REGIONAL
      autoCreateSubnetworks: false
    ---
    apiVersion: iam.cnrm.cloud.google.com/v1beta1
    kind: IAMServiceAccount
    metadata:
      annotations:
        # Replace ${PROJECT_ID?} with your project ID.
        cnrm.cloud.google.com/project-id: "${PROJECT_ID?}"
      name: firewallpolicyrule-dep

> [!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).