-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Network Firewall Policy Policy Packet Mirroring Rule resource #12855
Merged
roaks3
merged 2 commits into
GoogleCloudPlatform:main
from
mihhalj:packet-mirroring-rule-resource
Jan 31, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
197 changes: 197 additions & 0 deletions
197
mmv1/products/compute/NetworkFirewallPolicyPacketMirroringRule.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# Copyright 2024 Google Inc. | ||
# 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. | ||
|
||
--- | ||
name: 'NetworkFirewallPolicyPacketMirroringRule' | ||
api_resource_type_kind: FirewallPolicy | ||
kind: 'compute#packetMirroringRule' | ||
min_version: 'beta' | ||
description: | | ||
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). | ||
references: | ||
guides: | ||
api: 'https://cloud.google.com/compute/docs/reference/rest/beta/networkFirewallPolicies/addPacketMirroringRule' | ||
docs: | ||
id_format: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/packetMirroringRules/{{priority}}' | ||
base_url: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}' | ||
self_link: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/getPacketMirroringRule?priority={{priority}}' | ||
create_url: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/addPacketMirroringRule' | ||
update_url: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/patchPacketMirroringRule?priority={{priority}}' | ||
update_verb: 'POST' | ||
delete_url: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/removePacketMirroringRule?priority={{priority}}' | ||
delete_verb: 'POST' | ||
legacy_long_form_project: true | ||
import_format: | ||
- 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/packetMirroringRules/{{priority}}' | ||
timeouts: | ||
insert_minutes: 20 | ||
update_minutes: 20 | ||
delete_minutes: 20 | ||
async: | ||
actions: ['create', 'delete', 'update'] | ||
type: 'OpAsync' | ||
operation: | ||
base_url: '{{op_id}}' | ||
result: | ||
resource_inside_response: false | ||
examples: | ||
- name: 'compute_network_firewall_policy_packet_mirroring_rule' | ||
primary_resource_id: 'primary' | ||
vars: | ||
fw_policy: 'fw-policy' | ||
network_name: 'fw-network' | ||
tag_key: 'tag-key' | ||
tag_value: 'tag-value' | ||
deployment_group_id: 'deployment-group' | ||
endpoint_group_id: 'endpoint-group' | ||
security_profile_name: 'sec-profile' | ||
security_profile_group_name: 'sec-profile-group' | ||
test_env_vars: | ||
project_name: 'PROJECT_NAME' | ||
org_id: 'ORG_ID' | ||
parameters: | ||
- name: 'firewallPolicy' | ||
type: ResourceRef | ||
description: | | ||
The firewall policy of the resource. | ||
url_param_only: true | ||
required: true | ||
immutable: true | ||
diff_suppress_func: 'tpgresource.CompareResourceNames' | ||
resource: 'NetworkFirewallPolicy' | ||
imports: 'name' | ||
properties: | ||
- name: 'creationTimestamp' | ||
type: String | ||
description: | | ||
Creation timestamp in RFC3339 text format. | ||
output: true | ||
- name: 'kind' | ||
type: String | ||
description: | | ||
Type of the resource. Always `compute#packetMirroringRule` for firewall policy packet mirroring rules | ||
output: true | ||
- name: 'ruleName' | ||
type: String | ||
description: | | ||
An optional name for the rule. This field is not a unique identifier and can be updated. | ||
- name: 'description' | ||
type: String | ||
description: 'An optional description for this resource.' | ||
- name: 'priority' | ||
type: Integer | ||
immutable: true | ||
description: | | ||
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 priority. | ||
required: true | ||
- name: 'match' | ||
type: NestedObject | ||
description: | | ||
A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced. | ||
required: true | ||
properties: | ||
- name: 'srcIpRanges' | ||
type: Array | ||
send_empty_value: true | ||
description: | | ||
CIDR IP address range. Maximum number of source CIDR IP ranges allowed is 5000. | ||
item_type: | ||
type: String | ||
- name: 'destIpRanges' | ||
type: Array | ||
send_empty_value: true | ||
description: | | ||
CIDR IP address range. Maximum number of destination CIDR IP ranges allowed is 5000. | ||
item_type: | ||
type: String | ||
- name: 'layer4Configs' | ||
type: Array | ||
send_empty_value: true | ||
description: | | ||
Pairs of IP protocols and ports that the rule should match. | ||
required: true | ||
item_type: | ||
type: NestedObject | ||
properties: | ||
- name: 'ipProtocol' | ||
type: String | ||
description: | | ||
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. | ||
required: true | ||
- name: 'ports' | ||
type: Array | ||
description: | | ||
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"]. | ||
item_type: | ||
type: String | ||
- name: 'action' | ||
type: String | ||
description: 'The Action to perform when the client connection triggers the rule. Valid actions are "mirror", "do_not_mirror", "goto_next".' | ||
required: true | ||
- name: 'securityProfileGroup' | ||
type: String | ||
description: | | ||
A fully-qualified URL of a SecurityProfile resource instance. | ||
Example: https://networksecurity.googleapis.com/v1/projects/{project}/locations/{location}/securityProfileGroups/my-security-profile-group | ||
Must be specified if action = 'mirror' and cannot be specified for other actions. | ||
- name: 'targetSecureTags' | ||
type: Array | ||
send_empty_value: true | ||
description: | | ||
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 targetSecureTag 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. | ||
item_type: | ||
type: NestedObject | ||
properties: | ||
- name: 'name' | ||
type: String | ||
description: | | ||
Name of the secure tag, created with TagManager's TagValue API. | ||
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName' | ||
- name: 'state' | ||
type: Enum | ||
description: | | ||
State of the secure tag, either EFFECTIVE or INEFFECTIVE. A secure tag is INEFFECTIVE when it is deleted or its network is deleted. | ||
output: true | ||
enum_values: | ||
- 'EFFECTIVE' | ||
- 'INEFFECTIVE' | ||
- name: 'tlsInspect' | ||
type: Boolean | ||
description: | | ||
Boolean flag indicating if the traffic should be TLS decrypted. | ||
Can be set only if action = 'mirror' and cannot be set for other actions. | ||
- name: 'direction' | ||
type: Enum | ||
description: | | ||
The direction in which this rule applies. | ||
required: true | ||
enum_values: | ||
- 'INGRESS' | ||
- 'EGRESS' | ||
- name: 'ruleTupleCount' | ||
type: Integer | ||
description: | | ||
Calculation of the complexity of a single firewall policy rule. | ||
output: true | ||
- name: 'disabled' | ||
type: Boolean | ||
description: | | ||
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. |
91 changes: 91 additions & 0 deletions
91
...emplates/terraform/examples/compute_network_firewall_policy_packet_mirroring_rule.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
data "google_project" "project" { | ||
provider = google-beta | ||
} | ||
|
||
resource "google_compute_network" "default" { | ||
provider = google-beta | ||
name = "{{index $.Vars "network_name"}}" | ||
auto_create_subnetworks = false | ||
} | ||
|
||
resource "google_compute_network_firewall_policy" "basic_network_firewall_policy" { | ||
provider = google-beta | ||
name = "{{index $.Vars "fw_policy"}}" | ||
description = "Sample global network firewall policy" | ||
project = "{{index $.TestEnvVars "project_name"}}" | ||
} | ||
|
||
resource "google_compute_network_firewall_policy_packet_mirroring_rule" "{{$.PrimaryResourceId}}" { | ||
provider = google-beta | ||
action = "mirror" | ||
description = "This is a simple packet mirroring rule description" | ||
direction = "INGRESS" | ||
disabled = false | ||
firewall_policy = google_compute_network_firewall_policy.basic_network_firewall_policy.name | ||
priority = 1000 | ||
rule_name = "test-rule" | ||
|
||
match { | ||
src_ip_ranges = ["10.100.0.1/32"] | ||
layer4_configs { | ||
ip_protocol = "all" | ||
} | ||
} | ||
security_profile_group = "//networksecurity.googleapis.com/${google_network_security_security_profile_group.security_profile_group_1.id}" | ||
|
||
target_secure_tags { | ||
name = "tagValues/${google_tags_tag_value.secure_tag_value_1.name}" | ||
} | ||
} | ||
|
||
resource "google_network_security_mirroring_deployment_group" "default" { | ||
provider = google-beta | ||
mirroring_deployment_group_id = "{{index $.Vars "deployment_group_id"}}" | ||
location = "global" | ||
network = google_compute_network.default.id | ||
} | ||
|
||
resource "google_network_security_mirroring_endpoint_group" "default" { | ||
provider = google-beta | ||
mirroring_endpoint_group_id = "{{index $.Vars "endpoint_group_id"}}" | ||
location = "global" | ||
mirroring_deployment_group = google_network_security_mirroring_deployment_group.default.id | ||
} | ||
|
||
resource "google_network_security_security_profile" "default" { | ||
provider = google-beta | ||
name = "{{index $.Vars "security_profile_name"}}" | ||
parent = "organizations/{{index $.TestEnvVars "org_id"}}" | ||
description = "my description" | ||
type = "CUSTOM_MIRRORING" | ||
|
||
custom_mirroring_profile { | ||
mirroring_endpoint_group = google_network_security_mirroring_endpoint_group.default.id | ||
} | ||
} | ||
|
||
resource "google_network_security_security_profile_group" "security_profile_group_1" { | ||
provider = google-beta | ||
name = "{{index $.Vars "security_profile_group_name"}}" | ||
parent = "organizations/{{index $.TestEnvVars "org_id"}}" | ||
description = "my description" | ||
custom_mirroring_profile = google_network_security_security_profile.default.id | ||
} | ||
|
||
resource "google_tags_tag_key" "secure_tag_key_1" { | ||
provider = google-beta | ||
description = "Test tag key description" | ||
parent = "organizations/{{index $.TestEnvVars "org_id"}}" | ||
purpose = "GCE_FIREWALL" | ||
short_name = "{{index $.Vars "tag_key"}}" | ||
purpose_data = { | ||
network = "{{index $.TestEnvVars "project_name"}}/${google_compute_network.default.name}" | ||
} | ||
} | ||
|
||
resource "google_tags_tag_value" "secure_tag_value_1" { | ||
provider = google-beta | ||
description = "Test tag value description." | ||
parent = google_tags_tag_key.secure_tag_key_1.id | ||
short_name = "{{index $.Vars "tag_value"}}" | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind rebasing and then removing the fields that are no longer under
async
supported here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done