Skip to content

googleComputeRegionNetworkFirewallPolicyRule

The Compute NetworkFirewallPolicyRule resource

Example Usage - regional

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNetworkBasicNetwork =
  new google.computeNetwork.ComputeNetwork(this, "basic_network", {
    name: "network",
  });
const googleComputeRegionNetworkFirewallPolicyBasicRegionalNetworkFirewallPolicy =
  new google.computeRegionNetworkFirewallPolicy.ComputeRegionNetworkFirewallPolicy(
    this,
    "basic_regional_network_firewall_policy",
    {
      description: "Sample regional network firewall policy",
      name: "policy",
      project: "my-project-name",
      region: "us-west1",
    }
  );
const googleTagsTagKeyBasicKey = new google.tagsTagKey.TagsTagKey(
  this,
  "basic_key",
  {
    description: "For keyname resources.",
    parent: "organizations/123456789",
    purpose: "GCE_FIREWALL",
    purpose_data: [
      {
        network: `my-project-name/\${${googleComputeNetworkBasicNetwork.name}}`,
      },
    ],
    short_name: "tagkey",
  }
);
const googleTagsTagValueBasicValue = new google.tagsTagValue.TagsTagValue(
  this,
  "basic_value",
  {
    description: "For valuename resources.",
    parent: `tagKeys/\${${googleTagsTagKeyBasicKey.name}}`,
    short_name: "tagvalue",
  }
);
new google.computeRegionNetworkFirewallPolicyRule.ComputeRegionNetworkFirewallPolicyRule(
  this,
  "primary",
  {
    action: "allow",
    description: "This is a simple rule description",
    direction: "INGRESS",
    disabled: false,
    enable_logging: true,
    firewall_policy:
      googleComputeRegionNetworkFirewallPolicyBasicRegionalNetworkFirewallPolicy.name,
    match: [
      {
        layer4_configs: [
          {
            ip_protocol: "all",
          },
        ],
        src_ip_ranges: ["10.100.0.1/32"],
        src_secure_tags: [
          {
            name: `tagValues/\${${googleTagsTagValueBasicValue.name}}`,
          },
        ],
      },
    ],
    priority: 1000,
    region: "us-west1",
    rule_name: "test-rule",
    target_service_accounts: ["my@service-account.com"],
  }
);

Argument Reference

The following arguments are supported:

  • action - (Required) The Action to perform when the client connection triggers the rule. Can currently be either "allow" or "deny()" where valid values for status are 403, 404, and 502.

  • direction - (Required) The direction in which this rule applies. Possible values: INGRESS, EGRESS

  • firewallPolicy - (Required) The firewall policy of the resource.

  • match - (Required) A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced.

  • priority - (Required) 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.

The match block supports:

  • destIpRanges - (Optional) CIDR IP address range. Maximum number of destination CIDR IP ranges allowed is 5000.

  • layer4Configs - (Required) Pairs of IP protocols and ports that the rule should match.

  • srcIpRanges - (Optional) CIDR IP address range. Maximum number of source CIDR IP ranges allowed is 5000.

  • srcSecureTags - (Optional) List of secure tag values, which should be matched at the source of the traffic. For INGRESS rule, if all the srcSecureTag are INEFFECTIVE, and there is no srcIpRange, this rule will be ignored. Maximum number of source tag values allowed is 256.

The layer4Configs block supports:

  • ipProtocol - (Required) 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.

  • ports - (Optional) 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: ``.


  • description - (Optional) An optional description for this resource.

  • disabled - (Optional) 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) 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.

  • region - (Optional) The location of this resource.

  • project - (Optional) The project for the resource

  • ruleName - (Optional) An optional name for the rule. This field is not a unique identifier and can be updated.

  • targetSecureTags - (Optional) A list of secure tags that controls which instances the firewall rule applies to. If targetSecureTag are specified, then the firewall rule applies only to instances in the VPC network that have one of those EFFECTIVE secure tags, if all the target_secure_tag are in INEFFECTIVE state, then this rule will be ignored. targetSecureTag may not be set at the same time as targetServiceAccounts. If neither targetServiceAccounts nor targetSecureTag are specified, the firewall rule applies to all instances on the specified network. Maximum number of target label tags allowed is 256.

  • targetServiceAccounts - (Optional) A list of service accounts indicating the sets of instances that are applied with this rule.

The srcSecureTags block supports:

  • name - (Required) Name of the secure tag, created with TagManager's TagValue API. @pattern tagValues/[0-9]+

  • state - [Output Only] State of the secure tag, either effective or ineffective. A secure tag is ineffective when it is deleted or its network is deleted.

The targetSecureTags block supports:

  • name - (Required) Name of the secure tag, created with TagManager's TagValue API. @pattern tagValues/[0-9]+

  • state - [Output Only] State of the secure tag, either effective or ineffective. A secure tag is ineffective when it is deleted or its network is deleted.

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}}/regions/{{region}}/firewallPolicies/{{firewallPolicy}}/{{priority}}

  • kind - Type of the resource. Always compute#firewallPolicyRule for firewall policy rules

  • ruleTupleCount - Calculation of the complexity of a single firewall policy rule.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

NetworkFirewallPolicyRule can be imported using any of these accepted formats:

$ terraform import google_compute_region_network_firewall_policy_rule.default projects/{{project}}/regions/{{region}}/firewallPolicies/{{firewall_policy}}/{{priority}}
$ terraform import google_compute_region_network_firewall_policy_rule.default {{project}}/{{region}}/{{firewall_policy}}/{{priority}}
$ terraform import google_compute_region_network_firewall_policy_rule.default {{region}}/{{firewall_policy}}/{{priority}}
$ terraform import google_compute_region_network_firewall_policy_rule.default {{firewall_policy}}/{{priority}}