Skip to content

Commit 267eb08

Browse files
Add Network Firewall Policy Policy Packet Mirroring Rule resource (#12855) (#21196)
[upstream:bc0b2a950500c7b7ac185e34a3706e6c9f393ce9] Signed-off-by: Modular Magician <[email protected]>
1 parent 6d3489f commit 267eb08

File tree

3 files changed

+296
-0
lines changed

3 files changed

+296
-0
lines changed

.changelog/12855.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_compute_network_firewall_policy_packet_mirroring_rule` (beta)
3+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
package compute_test
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** Type: MMv1 ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This file is automatically generated by Magic Modules and manual
9+
# changes will be clobbered when the file is regenerated.
10+
#
11+
# Please read more about how to change this file in
12+
# .github/CONTRIBUTING.md.
13+
#
14+
# ----------------------------------------------------------------------------
15+
subcategory: "Compute Engine"
16+
description: |-
17+
Represents a packet mirroring rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (mirror or do_not_mirror).
18+
---
19+
20+
# google_compute_network_firewall_policy_packet_mirroring_rule
21+
22+
Represents a packet mirroring rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (mirror or do_not_mirror).
23+
24+
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
25+
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
26+
27+
To get more information about NetworkFirewallPolicyPacketMirroringRule, see:
28+
29+
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/networkFirewallPolicies/addPacketMirroringRule)
30+
31+
## Example Usage - Compute Network Firewall Policy Packet Mirroring Rule
32+
33+
34+
```hcl
35+
data "google_project" "project" {
36+
provider = google-beta
37+
}
38+
39+
resource "google_compute_network" "default" {
40+
provider = google-beta
41+
name = "fw-network"
42+
auto_create_subnetworks = false
43+
}
44+
45+
resource "google_compute_network_firewall_policy" "basic_network_firewall_policy" {
46+
provider = google-beta
47+
name = "fw-policy"
48+
description = "Sample global network firewall policy"
49+
project = "my-project-name"
50+
}
51+
52+
resource "google_compute_network_firewall_policy_packet_mirroring_rule" "primary" {
53+
provider = google-beta
54+
action = "mirror"
55+
description = "This is a simple packet mirroring rule description"
56+
direction = "INGRESS"
57+
disabled = false
58+
firewall_policy = google_compute_network_firewall_policy.basic_network_firewall_policy.name
59+
priority = 1000
60+
rule_name = "test-rule"
61+
62+
match {
63+
src_ip_ranges = ["10.100.0.1/32"]
64+
layer4_configs {
65+
ip_protocol = "all"
66+
}
67+
}
68+
security_profile_group = "//networksecurity.googleapis.com/${google_network_security_security_profile_group.security_profile_group_1.id}"
69+
70+
target_secure_tags {
71+
name = "tagValues/${google_tags_tag_value.secure_tag_value_1.name}"
72+
}
73+
}
74+
75+
resource "google_network_security_mirroring_deployment_group" "default" {
76+
provider = google-beta
77+
mirroring_deployment_group_id = "deployment-group"
78+
location = "global"
79+
network = google_compute_network.default.id
80+
}
81+
82+
resource "google_network_security_mirroring_endpoint_group" "default" {
83+
provider = google-beta
84+
mirroring_endpoint_group_id = "endpoint-group"
85+
location = "global"
86+
mirroring_deployment_group = google_network_security_mirroring_deployment_group.default.id
87+
}
88+
89+
resource "google_network_security_security_profile" "default" {
90+
provider = google-beta
91+
name = "sec-profile"
92+
parent = "organizations/123456789"
93+
description = "my description"
94+
type = "CUSTOM_MIRRORING"
95+
96+
custom_mirroring_profile {
97+
mirroring_endpoint_group = google_network_security_mirroring_endpoint_group.default.id
98+
}
99+
}
100+
101+
resource "google_network_security_security_profile_group" "security_profile_group_1" {
102+
provider = google-beta
103+
name = "sec-profile-group"
104+
parent = "organizations/123456789"
105+
description = "my description"
106+
custom_mirroring_profile = google_network_security_security_profile.default.id
107+
}
108+
109+
resource "google_tags_tag_key" "secure_tag_key_1" {
110+
provider = google-beta
111+
description = "Test tag key description"
112+
parent = "organizations/123456789"
113+
purpose = "GCE_FIREWALL"
114+
short_name = "tag-key"
115+
purpose_data = {
116+
network = "my-project-name/${google_compute_network.default.name}"
117+
}
118+
}
119+
120+
resource "google_tags_tag_value" "secure_tag_value_1" {
121+
provider = google-beta
122+
description = "Test tag value description."
123+
parent = google_tags_tag_key.secure_tag_key_1.id
124+
short_name = "tag-value"
125+
}
126+
```
127+
128+
## Argument Reference
129+
130+
The following arguments are supported:
131+
132+
133+
* `priority` -
134+
(Required)
135+
An integer indicating the priority of a rule in the list.
136+
The priority must be a positive value between 0 and 2147483647.
137+
Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest priority.
138+
139+
* `match` -
140+
(Required)
141+
A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced.
142+
Structure is [documented below](#nested_match).
143+
144+
* `action` -
145+
(Required)
146+
The Action to perform when the client connection triggers the rule. Valid actions are "mirror", "do_not_mirror", "goto_next".
147+
148+
* `direction` -
149+
(Required)
150+
The direction in which this rule applies.
151+
Possible values are: `INGRESS`, `EGRESS`.
152+
153+
* `firewall_policy` -
154+
(Required)
155+
The firewall policy of the resource.
156+
157+
158+
<a name="nested_match"></a>The `match` block supports:
159+
160+
* `src_ip_ranges` -
161+
(Optional)
162+
CIDR IP address range. Maximum number of source CIDR IP ranges allowed is 5000.
163+
164+
* `dest_ip_ranges` -
165+
(Optional)
166+
CIDR IP address range. Maximum number of destination CIDR IP ranges allowed is 5000.
167+
168+
* `layer4_configs` -
169+
(Required)
170+
Pairs of IP protocols and ports that the rule should match.
171+
Structure is [documented below](#nested_match_layer4_configs).
172+
173+
174+
<a name="nested_match_layer4_configs"></a>The `layer4_configs` block supports:
175+
176+
* `ip_protocol` -
177+
(Required)
178+
The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule.
179+
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.
180+
181+
* `ports` -
182+
(Optional)
183+
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.
184+
Example inputs include: ["22"], ["80","443"], and ["12345-12349"].
185+
186+
- - -
187+
188+
189+
* `rule_name` -
190+
(Optional)
191+
An optional name for the rule. This field is not a unique identifier and can be updated.
192+
193+
* `description` -
194+
(Optional)
195+
An optional description for this resource.
196+
197+
* `security_profile_group` -
198+
(Optional)
199+
A fully-qualified URL of a SecurityProfile resource instance.
200+
Example: https://networksecurity.googleapis.com/v1/projects/{project}/locations/{location}/securityProfileGroups/my-security-profile-group
201+
Must be specified if action = 'mirror' and cannot be specified for other actions.
202+
203+
* `target_secure_tags` -
204+
(Optional)
205+
A list of secure tags that controls which instances the firewall rule applies to.
206+
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 targetSecureTag are in INEFFECTIVE state, then this rule will be ignored.
207+
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.
208+
Structure is [documented below](#nested_target_secure_tags).
209+
210+
* `tls_inspect` -
211+
(Optional)
212+
Boolean flag indicating if the traffic should be TLS decrypted.
213+
Can be set only if action = 'mirror' and cannot be set for other actions.
214+
215+
* `disabled` -
216+
(Optional)
217+
Denotes whether the firewall policy rule is disabled.
218+
When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist.
219+
If this is unspecified, the firewall policy rule will be enabled.
220+
221+
* `project` - (Optional) The ID of the project in which the resource belongs.
222+
If it is not provided, the provider project is used.
223+
224+
225+
<a name="nested_target_secure_tags"></a>The `target_secure_tags` block supports:
226+
227+
* `name` -
228+
(Optional)
229+
Name of the secure tag, created with TagManager's TagValue API.
230+
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName'
231+
232+
* `state` -
233+
(Output)
234+
State of the secure tag, either EFFECTIVE or INEFFECTIVE. A secure tag is INEFFECTIVE when it is deleted or its network is deleted.
235+
236+
## Attributes Reference
237+
238+
In addition to the arguments listed above, the following computed attributes are exported:
239+
240+
* `id` - an identifier for the resource with format `projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/packetMirroringRules/{{priority}}`
241+
242+
* `creation_timestamp` -
243+
Creation timestamp in RFC3339 text format.
244+
245+
* `kind` -
246+
Type of the resource. Always `compute#packetMirroringRule` for firewall policy packet mirroring rules
247+
248+
* `rule_tuple_count` -
249+
Calculation of the complexity of a single firewall policy rule.
250+
251+
252+
## Timeouts
253+
254+
This resource provides the following
255+
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
256+
257+
- `create` - Default is 20 minutes.
258+
- `update` - Default is 20 minutes.
259+
- `delete` - Default is 20 minutes.
260+
261+
## Import
262+
263+
264+
NetworkFirewallPolicyPacketMirroringRule can be imported using any of these accepted formats:
265+
266+
* `projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/packetMirroringRules/{{priority}}`
267+
* `{{project}}/{{firewall_policy}}/{{priority}}`
268+
* `{{firewall_policy}}/{{priority}}`
269+
270+
271+
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import NetworkFirewallPolicyPacketMirroringRule using one of the formats above. For example:
272+
273+
```tf
274+
import {
275+
id = "projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/packetMirroringRules/{{priority}}"
276+
to = google_compute_network_firewall_policy_packet_mirroring_rule.default
277+
}
278+
```
279+
280+
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), NetworkFirewallPolicyPacketMirroringRule can be imported using one of the formats above. For example:
281+
282+
```
283+
$ terraform import google_compute_network_firewall_policy_packet_mirroring_rule.default projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/packetMirroringRules/{{priority}}
284+
$ terraform import google_compute_network_firewall_policy_packet_mirroring_rule.default {{project}}/{{firewall_policy}}/{{priority}}
285+
$ terraform import google_compute_network_firewall_policy_packet_mirroring_rule.default {{firewall_policy}}/{{priority}}
286+
```
287+
288+
## User Project Overrides
289+
290+
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).

0 commit comments

Comments
 (0)