Skip to content

Commit 4cb7e4c

Browse files
Samir-Cittrodge
authored andcommitted
Migrate Network Firewall Policy Rule (global and region) from DCL to MMv1 (GoogleCloudPlatform#11368)
Co-authored-by: Thomas Rodgers <[email protected]>
1 parent 8c89fca commit 4cb7e4c

8 files changed

+1712
-63
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'NetworkFirewallPolicyRule'
16+
kind: 'compute#firewallPolicyRule'
17+
description: |
18+
Represents a rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (allow or deny).
19+
references:
20+
guides:
21+
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/networkFirewallPolicies/addRule'
22+
docs:
23+
id_format: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/rules/{{priority}}'
24+
base_url: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}'
25+
self_link: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/getRule?priority={{priority}}'
26+
create_url: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/addRule'
27+
update_url: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/patchRule?priority={{priority}}'
28+
update_verb: 'POST'
29+
delete_url: 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/removeRule?priority={{priority}}'
30+
delete_verb: 'POST'
31+
legacy_long_form_project: true
32+
import_format:
33+
- 'projects/{{project}}/global/firewallPolicies/{{firewall_policy}}/rules/{{priority}}'
34+
- '{{project}}/{{firewall_policy}}/{{priority}}'
35+
- '{{firewall_policy}}/{{priority}}'
36+
timeouts:
37+
insert_minutes: 20
38+
update_minutes: 20
39+
delete_minutes: 20
40+
async:
41+
actions: ['create', 'delete', 'update']
42+
type: 'OpAsync'
43+
operation:
44+
base_url: '{{op_id}}'
45+
kind: 'compute#operation'
46+
path: 'name'
47+
wait_ms: 1000
48+
result:
49+
path: 'targetLink'
50+
resource_inside_response: false
51+
error:
52+
path: 'error/errors'
53+
message: 'message'
54+
examples:
55+
- name: 'network_firewall_policy_rule'
56+
primary_resource_id: 'primary'
57+
vars:
58+
tag_key: 'tagkey'
59+
network: 'network'
60+
fw_policy: 'policy'
61+
address: 'address'
62+
test_env_vars:
63+
project_name: 'PROJECT_NAME'
64+
org_id: 'ORG_ID'
65+
service_acct: 'SERVICE_ACCT'
66+
parameters:
67+
- name: 'firewallPolicy'
68+
type: ResourceRef
69+
description: |
70+
The firewall policy of the resource.
71+
url_param_only: true
72+
required: true
73+
immutable: true
74+
diff_suppress_func: 'tpgresource.CompareResourceNames'
75+
resource: 'NetworkFirewallPolicy'
76+
imports: 'name'
77+
properties:
78+
- name: 'creationTimestamp'
79+
type: String
80+
description: |
81+
Creation timestamp in RFC3339 text format.
82+
output: true
83+
- name: 'kind'
84+
type: String
85+
description: |
86+
Type of the resource. Always `compute#firewallPolicyRule` for firewall policy rules
87+
output: true
88+
- name: 'ruleName'
89+
type: String
90+
description: |
91+
An optional name for the rule. This field is not a unique identifier and can be updated.
92+
- name: 'description'
93+
type: String
94+
description: 'An optional description for this resource.'
95+
- name: 'priority'
96+
type: Integer
97+
immutable: true
98+
description: |
99+
An integer indicating the priority of a rule in the list.
100+
The priority must be a positive value between 0 and 2147483647.
101+
Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest prority.
102+
required: true
103+
- name: 'match'
104+
type: NestedObject
105+
description: |
106+
A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced.
107+
required: true
108+
properties:
109+
- name: 'srcIpRanges'
110+
type: Array
111+
send_empty_value: true
112+
description: |
113+
CIDR IP address range. Maximum number of source CIDR IP ranges allowed is 5000.
114+
item_type:
115+
type: String
116+
- name: 'destIpRanges'
117+
type: Array
118+
send_empty_value: true
119+
description: |
120+
CIDR IP address range. Maximum number of destination CIDR IP ranges allowed is 5000.
121+
item_type:
122+
type: String
123+
- name: 'layer4Configs'
124+
type: Array
125+
send_empty_value: true
126+
description: |
127+
Pairs of IP protocols and ports that the rule should match.
128+
required: true
129+
item_type:
130+
type: NestedObject
131+
properties:
132+
- name: 'ipProtocol'
133+
type: String
134+
description: |
135+
The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule.
136+
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.
137+
required: true
138+
- name: 'ports'
139+
type: Array
140+
description: |
141+
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.
142+
Example inputs include: ["22"], ["80","443"], and ["12345-12349"].
143+
item_type:
144+
type: String
145+
- name: 'srcSecureTags'
146+
type: Array
147+
send_empty_value: true
148+
description: |
149+
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.
150+
item_type:
151+
type: NestedObject
152+
properties:
153+
- name: 'name'
154+
type: String
155+
description: |
156+
Name of the secure tag, created with TagManager's TagValue API.
157+
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName'
158+
- name: 'state'
159+
type: Enum
160+
description: |
161+
State of the secure tag, either EFFECTIVE or INEFFECTIVE. A secure tag is INEFFECTIVE when it is deleted or its network is deleted.
162+
output: true
163+
enum_values:
164+
- 'EFFECTIVE'
165+
- 'INEFFECTIVE'
166+
- name: 'destAddressGroups'
167+
type: Array
168+
send_empty_value: true
169+
description: |
170+
Address groups which should be matched against the traffic destination. Maximum number of destination address groups is 10.
171+
item_type:
172+
type: String
173+
- name: 'srcAddressGroups'
174+
type: Array
175+
send_empty_value: true
176+
description: |
177+
Address groups which should be matched against the traffic source. Maximum number of source address groups is 10.
178+
item_type:
179+
type: String
180+
- name: 'srcFqdns'
181+
type: Array
182+
send_empty_value: true
183+
description: |
184+
Fully Qualified Domain Name (FQDN) which should be matched against traffic source. Maximum number of source fqdn allowed is 100.
185+
item_type:
186+
type: String
187+
- name: 'destFqdns'
188+
type: Array
189+
send_empty_value: true
190+
description: |
191+
Fully Qualified Domain Name (FQDN) which should be matched against traffic destination. Maximum number of destination fqdn allowed is 100.
192+
item_type:
193+
type: String
194+
- name: 'srcRegionCodes'
195+
type: Array
196+
send_empty_value: true
197+
description: |
198+
Region codes whose IP addresses will be used to match for source of traffic. Should be specified as 2 letter country code defined as per ISO 3166 alpha-2 country codes. ex."US" Maximum number of source region codes allowed is 5000.
199+
item_type:
200+
type: String
201+
- name: 'destRegionCodes'
202+
type: Array
203+
send_empty_value: true
204+
description: |
205+
Region codes whose IP addresses will be used to match for destination of traffic. Should be specified as 2 letter country code defined as per ISO 3166 alpha-2 country codes. ex."US" Maximum number of dest region codes allowed is 5000.
206+
item_type:
207+
type: String
208+
- name: 'destThreatIntelligences'
209+
type: Array
210+
send_empty_value: true
211+
description: |
212+
Names of Network Threat Intelligence lists. The IPs in these lists will be matched against traffic destination.
213+
item_type:
214+
type: String
215+
- name: 'srcThreatIntelligences'
216+
type: Array
217+
send_empty_value: true
218+
description: |
219+
Names of Network Threat Intelligence lists. The IPs in these lists will be matched against traffic source.
220+
item_type:
221+
type: String
222+
- name: 'action'
223+
type: String
224+
description: 'The Action to perform when the client connection triggers the rule. Valid actions are "allow", "deny", "goto_next" and "apply_security_profile_group".'
225+
required: true
226+
- name: 'securityProfileGroup'
227+
type: String
228+
description: |
229+
A fully-qualified URL of a SecurityProfile resource instance.
230+
Example: https://networksecurity.googleapis.com/v1/projects/{project}/locations/{location}/securityProfileGroups/my-security-profile-group
231+
Must be specified if action = 'apply_security_profile_group' and cannot be specified for other actions.
232+
- name: 'tlsInspect'
233+
type: Boolean
234+
description: |
235+
Boolean flag indicating if the traffic should be TLS decrypted.
236+
Can be set only if action = 'apply_security_profile_group' and cannot be set for other actions.
237+
- name: 'direction'
238+
type: Enum
239+
description: |
240+
The direction in which this rule applies.
241+
required: true
242+
enum_values:
243+
- 'INGRESS'
244+
- 'EGRESS'
245+
- name: 'enableLogging'
246+
type: Boolean
247+
send_empty_value: true
248+
description: |
249+
Denotes whether to enable logging for a particular rule.
250+
If logging is enabled, logs will be exported to the configured export destination in Stackdriver.
251+
Logs may be exported to BigQuery or Pub/Sub.
252+
Note: you cannot enable logging on "goto_next" rules.
253+
- name: 'ruleTupleCount'
254+
type: Integer
255+
description: |
256+
Calculation of the complexity of a single firewall policy rule.
257+
output: true
258+
- name: 'targetServiceAccounts'
259+
type: Array
260+
send_empty_value: true
261+
description: |
262+
A list of service accounts indicating the sets of instances that are applied with this rule.
263+
item_type:
264+
type: String
265+
- name: 'targetSecureTags'
266+
type: Array
267+
send_empty_value: true
268+
description: |
269+
A list of secure tags that controls which instances the firewall rule applies to.
270+
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.
271+
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.
272+
item_type:
273+
type: NestedObject
274+
properties:
275+
- name: 'name'
276+
type: String
277+
description: |
278+
Name of the secure tag, created with TagManager's TagValue API.
279+
diff_suppress_func: 'tpgresource.CompareSelfLinkOrResourceName'
280+
- name: 'state'
281+
type: Enum
282+
description: |
283+
State of the secure tag, either EFFECTIVE or INEFFECTIVE. A secure tag is INEFFECTIVE when it is deleted or its network is deleted.
284+
output: true
285+
enum_values:
286+
- 'EFFECTIVE'
287+
- 'INEFFECTIVE'
288+
- name: 'disabled'
289+
type: Boolean
290+
description: |
291+
Denotes whether the firewall policy rule is disabled.
292+
When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist.
293+
If this is unspecified, the firewall policy rule will be enabled.

0 commit comments

Comments
 (0)