Skip to content

Commit c8a2b12

Browse files
LucaPreteLuca Prete
authored andcommitted
Add support for secure tags to (hierarchical) FirewallPolicyWithRules (GoogleCloudPlatform#14380)
Co-authored-by: Luca Prete <[email protected]>
1 parent 0b4bbf2 commit c8a2b12

File tree

3 files changed

+311
-53
lines changed

3 files changed

+311
-53
lines changed

mmv1/products/compute/FirewallPolicyWithRules.yaml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ examples:
4646
network: 'network'
4747
security_profile: 'sp'
4848
security_profile_group: 'spg'
49+
tag_key: 'tag-key'
50+
tag_value: 'tag-value'
4951
test_env_vars:
5052
org_id: 'ORG_ID'
5153
parameters:
@@ -206,6 +208,33 @@ properties:
206208
The IPs in these lists will be matched against traffic destination.
207209
item_type:
208210
type: String
211+
- name: 'srcSecureTag'
212+
type: Array
213+
description: |
214+
List of secure tag values, which should be matched at the source
215+
of the traffic.
216+
For INGRESS rule, if all the <code>srcSecureTag</code> are INEFFECTIVE,
217+
and there is no <code>srcIpRange</code>, this rule will be ignored.
218+
Maximum number of source tag values allowed is 256.
219+
api_name: srcSecureTags
220+
item_type:
221+
type: NestedObject
222+
properties:
223+
- name: 'name'
224+
type: String
225+
description: |
226+
Name of the secure tag, created with TagManager's TagValue API.
227+
@pattern tagValues/[0-9]+
228+
- name: 'state'
229+
type: Enum
230+
description: |
231+
[Output Only] State of the secure tag, either `EFFECTIVE` or
232+
`INEFFECTIVE`. A secure tag is `INEFFECTIVE` when it is deleted
233+
or its network is deleted.
234+
output: true
235+
enum_values:
236+
- 'EFFECTIVE'
237+
- 'INEFFECTIVE'
209238
- name: 'layer4Config'
210239
type: Array
211240
description: |
@@ -235,6 +264,39 @@ properties:
235264
["12345-12349"].
236265
item_type:
237266
type: String
267+
- name: 'targetSecureTag'
268+
type: Array
269+
description: |
270+
A list of secure tags that controls which instances the firewall rule
271+
applies to. If <code>targetSecureTag</code> are specified, then the
272+
firewall rule applies only to instances in the VPC network that have one
273+
of those EFFECTIVE secure tags, if all the target_secure_tag are in
274+
INEFFECTIVE state, then this rule will be ignored.
275+
<code>targetSecureTag</code> may not be set at the same time as
276+
<code>targetServiceAccounts</code>.
277+
If neither <code>targetServiceAccounts</code> nor
278+
<code>targetSecureTag</code> are specified, the firewall rule applies
279+
to all instances on the specified network.
280+
Maximum number of target secure tags allowed is 256.
281+
api_name: targetSecureTags
282+
item_type:
283+
type: NestedObject
284+
properties:
285+
- name: 'name'
286+
type: String
287+
description: |
288+
Name of the secure tag, created with TagManager's TagValue API.
289+
@pattern tagValues/[0-9]+
290+
- name: 'state'
291+
type: Enum
292+
description: |
293+
[Output Only] State of the secure tag, either `EFFECTIVE` or
294+
`INEFFECTIVE`. A secure tag is `INEFFECTIVE` when it is deleted
295+
or its network is deleted.
296+
output: true
297+
enum_values:
298+
- 'EFFECTIVE'
299+
- 'INEFFECTIVE'
238300
- name: 'action'
239301
type: String
240302
description: |
@@ -436,6 +498,70 @@ properties:
436498
output: true
437499
item_type:
438500
type: String
501+
- name: 'srcSecureTag'
502+
type: Array
503+
description: |
504+
List of secure tag values, which should be matched at the source
505+
of the traffic.
506+
For INGRESS rule, if all the <code>srcSecureTag</code> are INEFFECTIVE,
507+
and there is no <code>srcIpRange</code>, this rule will be ignored.
508+
Maximum number of source tag values allowed is 256.
509+
api_name: srcSecureTags
510+
output: true
511+
item_type:
512+
type: NestedObject
513+
properties:
514+
- name: 'name'
515+
type: String
516+
description: |
517+
Name of the secure tag, created with TagManager's TagValue API.
518+
@pattern tagValues/[0-9]+
519+
output: true
520+
- name: 'state'
521+
type: Enum
522+
description: |
523+
[Output Only] State of the secure tag, either `EFFECTIVE` or
524+
`INEFFECTIVE`. A secure tag is `INEFFECTIVE` when it is deleted
525+
or its network is deleted.
526+
output: true
527+
enum_values:
528+
- 'EFFECTIVE'
529+
- 'INEFFECTIVE'
530+
- name: 'targetSecureTag'
531+
type: Array
532+
description: |
533+
A list of secure tags that controls which instances the firewall rule
534+
applies to. If <code>targetSecureTag</code> are specified, then the
535+
firewall rule applies only to instances in the VPC network that have one
536+
of those EFFECTIVE secure tags, if all the target_secure_tag are in
537+
INEFFECTIVE state, then this rule will be ignored.
538+
<code>targetSecureTag</code> may not be set at the same time as
539+
<code>targetServiceAccounts</code>.
540+
If neither <code>targetServiceAccounts</code> nor
541+
<code>targetSecureTag</code> are specified, the firewall rule applies
542+
to all instances on the specified network.
543+
Maximum number of target secure tags allowed is 256.
544+
api_name: targetSecureTags
545+
output: true
546+
item_type:
547+
type: NestedObject
548+
properties:
549+
- name: 'name'
550+
type: String
551+
description: |
552+
Name of the secure tag, created with TagManager's TagValue API.
553+
@pattern tagValues/[0-9]+
554+
output: true
555+
- name: 'state'
556+
type: Enum
557+
description: |
558+
[Output Only] State of the secure tag, either `EFFECTIVE` or
559+
`INEFFECTIVE`. A secure tag is `INEFFECTIVE` when it is deleted
560+
or its network is deleted.
561+
output: true
562+
enum_values:
563+
- 'EFFECTIVE'
564+
- 'INEFFECTIVE'
439565
- name: 'action'
440566
type: String
441567
description: |

mmv1/templates/terraform/examples/compute_firewall_policy_with_rules_full.tf.tmpl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,32 @@ resource "google_compute_firewall_policy_with_rules" "{{$.PrimaryResourceId}}" {
6868
}
6969
}
7070
}
71+
72+
rule {
73+
description = "secure tags"
74+
rule_name = "secure tags rule"
75+
priority = 4000
76+
enable_logging = false
77+
action = "allow"
78+
direction = "INGRESS"
79+
80+
target_secure_tag {
81+
name = google_tags_tag_value.basic_value.id
82+
}
83+
84+
match {
85+
src_ip_ranges = ["11.100.0.1/32"]
86+
87+
src_secure_tag {
88+
name = google_tags_tag_value.basic_value.id
89+
}
90+
91+
layer4_config {
92+
ip_protocol = "tcp"
93+
ports = [8080]
94+
}
95+
}
96+
}
7197
}
7298

7399
resource "google_network_security_address_group" "address_group_1" {
@@ -98,3 +124,20 @@ resource "google_compute_network" "network" {
98124
name = "{{index $.Vars "network"}}"
99125
auto_create_subnetworks = false
100126
}
127+
128+
resource "google_tags_tag_key" "basic_key" {
129+
description = "For keyname resources."
130+
parent = "organizations/{{index $.TestEnvVars "org_id"}}"
131+
purpose = "GCE_FIREWALL"
132+
short_name = "{{index $.Vars "tag_key"}}"
133+
134+
purpose_data = {
135+
organization = "auto"
136+
}
137+
}
138+
139+
resource "google_tags_tag_value" "basic_value" {
140+
description = "For valuename resources."
141+
parent = google_tags_tag_key.basic_key.id
142+
short_name = "{{index $.Vars "tag_value"}}"
143+
}

0 commit comments

Comments
 (0)