A rule for the OrganizationSecurityPolicy.
To get more information about OrganizationSecurityPolicyRule, see:
resource "google_compute_organization_security_policy" "policy" {
provider = google-beta
display_name = "tf-test%{random_suffix}"
parent = "organizations/123456789"
}
resource "google_compute_organization_security_policy_rule" "policy" {
provider = google-beta
policy_id = google_compute_organization_security_policy.policy.id
action = "allow"
direction = "INGRESS"
enable_logging = true
match {
config {
src_ip_ranges = ["192.168.0.0/16", "10.0.0.0/8"]
layer4_config {
ip_protocol = "tcp"
ports = ["22"]
}
layer4_config {
ip_protocol = "icmp"
}
}
}
priority = 100
}
The following arguments are supported:
priority
-
(Required)
An integer indicating the priority of a rule in the list. The priority must be a 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.
match
-
(Required)
A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced.
Structure is documented below.
action
-
(Required)
The Action to perform when the client connection triggers the rule. Can currently be either
"allow", "deny" or "goto_next".
policy_id
-
(Required)
The ID of the OrganizationSecurityPolicy this rule applies to.
description
-
(Optional)
A description of the rule.
versioned_expr
-
(Optional)
Preconfigured versioned expression. For organization security policy rules,
the only supported type is "FIREWALL".
Default value is FIREWALL
.
Possible values are: FIREWALL
.
config
-
(Required)
The configuration options for matching the rule.
Structure is documented below.
src_ip_ranges
-
(Optional)
Source IP address range in CIDR format. Required for
INGRESS rules.
dest_ip_ranges
-
(Optional)
Destination IP address range in CIDR format. Required for
EGRESS rules.
layer4_config
-
(Required)
Pairs of IP protocols and ports that the rule should match.
Structure is documented below.
The layer4_config
block supports:
ip_protocol
-
(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: ["22"], ["80","443"], and
["12345-12349"].
description
-
(Optional)
A description of the rule.
preview
-
(Optional)
If set to true, the specified action is not enforced.
direction
-
(Optional)
The direction in which this rule applies. If unspecified an INGRESS rule is created.
Possible values are: INGRESS
, EGRESS
.
target_resources
-
(Optional)
A list of network resource URLs to which this rule applies.
This field allows you to control which network's VMs get
this rule. If this field is left blank, all VMs
within the organization will receive the rule.
enable_logging
-
(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.
target_service_accounts
-
(Optional)
A list of service accounts indicating the sets of
instances that are applied with this rule.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format {{policy_id}}/priority/{{priority}}
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.OrganizationSecurityPolicyRule can be imported using any of these accepted formats:
{{policy_id}}/priority/{{priority}}
In Terraform v1.5.0 and later, use an import
block to import OrganizationSecurityPolicyRule using one of the formats above. For example:
import {
id = "{{policy_id}}/priority/{{priority}}"
to = google_compute_organization_security_policy_rule.default
}
When using the terraform import
command, OrganizationSecurityPolicyRule can be imported using one of the formats above. For example:
$ terraform import google_compute_organization_security_policy_rule.default {{policy_id}}/priority/{{priority}}