@@ -177,6 +177,26 @@ Example inputs include: ["22"], ["80","443"], and ["12345-12349"].`,
177
177
Type : schema .TypeString ,
178
178
},
179
179
},
180
+ "src_secure_tags" : {
181
+ Type : schema .TypeList ,
182
+ Optional : true ,
183
+ Description : `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.` ,
184
+ Elem : & schema.Resource {
185
+ Schema : map [string ]* schema.Schema {
186
+ "name" : {
187
+ Type : schema .TypeString ,
188
+ Optional : true ,
189
+ DiffSuppressFunc : tpgresource .CompareSelfLinkOrResourceName ,
190
+ Description : `Name of the secure tag, created with TagManager's TagValue API.` ,
191
+ },
192
+ "state" : {
193
+ Type : schema .TypeString ,
194
+ Computed : true ,
195
+ Description : `State of the secure tag, either EFFECTIVE or INEFFECTIVE. A secure tag is INEFFECTIVE when it is deleted or its network is deleted.` ,
196
+ },
197
+ },
198
+ },
199
+ },
180
200
"src_threat_intelligences" : {
181
201
Type : schema .TypeList ,
182
202
Optional : true ,
@@ -234,6 +254,28 @@ If this field is left blank, all VMs within the organization will receive the ru
234
254
Type : schema .TypeString ,
235
255
},
236
256
},
257
+ "target_secure_tags" : {
258
+ Type : schema .TypeList ,
259
+ Optional : true ,
260
+ Description : `A list of secure tags that controls which instances the firewall rule applies to.
261
+ 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.
262
+ 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 secure tags allowed is 256.` ,
263
+ Elem : & schema.Resource {
264
+ Schema : map [string ]* schema.Schema {
265
+ "name" : {
266
+ Type : schema .TypeString ,
267
+ Optional : true ,
268
+ DiffSuppressFunc : tpgresource .CompareSelfLinkOrResourceName ,
269
+ Description : `Name of the secure tag, created with TagManager's TagValue API.` ,
270
+ },
271
+ "state" : {
272
+ Type : schema .TypeString ,
273
+ Computed : true ,
274
+ Description : `State of the secure tag, either EFFECTIVE or INEFFECTIVE. A secure tag is INEFFECTIVE when it is deleted or its network is deleted.` ,
275
+ },
276
+ },
277
+ },
278
+ },
237
279
"target_service_accounts" : {
238
280
Type : schema .TypeList ,
239
281
Optional : true ,
@@ -336,6 +378,12 @@ func resourceComputeFirewallPolicyRuleCreate(d *schema.ResourceData, meta interf
336
378
} else if v , ok := d .GetOkExists ("target_service_accounts" ); ok || ! reflect .DeepEqual (v , targetServiceAccountsProp ) {
337
379
obj ["targetServiceAccounts" ] = targetServiceAccountsProp
338
380
}
381
+ targetSecureTagsProp , err := expandComputeFirewallPolicyRuleTargetSecureTags (d .Get ("target_secure_tags" ), d , config )
382
+ if err != nil {
383
+ return err
384
+ } else if v , ok := d .GetOkExists ("target_secure_tags" ); ok || ! reflect .DeepEqual (v , targetSecureTagsProp ) {
385
+ obj ["targetSecureTags" ] = targetSecureTagsProp
386
+ }
339
387
disabledProp , err := expandComputeFirewallPolicyRuleDisabled (d .Get ("disabled" ), d , config )
340
388
if err != nil {
341
389
return err
@@ -472,6 +520,9 @@ func resourceComputeFirewallPolicyRuleRead(d *schema.ResourceData, meta interfac
472
520
if err := d .Set ("target_service_accounts" , flattenComputeFirewallPolicyRuleTargetServiceAccounts (res ["targetServiceAccounts" ], d , config )); err != nil {
473
521
return fmt .Errorf ("Error reading FirewallPolicyRule: %s" , err )
474
522
}
523
+ if err := d .Set ("target_secure_tags" , flattenComputeFirewallPolicyRuleTargetSecureTags (res ["targetSecureTags" ], d , config )); err != nil {
524
+ return fmt .Errorf ("Error reading FirewallPolicyRule: %s" , err )
525
+ }
475
526
if err := d .Set ("disabled" , flattenComputeFirewallPolicyRuleDisabled (res ["disabled" ], d , config )); err != nil {
476
527
return fmt .Errorf ("Error reading FirewallPolicyRule: %s" , err )
477
528
}
@@ -549,6 +600,12 @@ func resourceComputeFirewallPolicyRuleUpdate(d *schema.ResourceData, meta interf
549
600
} else if v , ok := d .GetOkExists ("target_service_accounts" ); ok || ! reflect .DeepEqual (v , targetServiceAccountsProp ) {
550
601
obj ["targetServiceAccounts" ] = targetServiceAccountsProp
551
602
}
603
+ targetSecureTagsProp , err := expandComputeFirewallPolicyRuleTargetSecureTags (d .Get ("target_secure_tags" ), d , config )
604
+ if err != nil {
605
+ return err
606
+ } else if v , ok := d .GetOkExists ("target_secure_tags" ); ok || ! reflect .DeepEqual (v , targetSecureTagsProp ) {
607
+ obj ["targetSecureTags" ] = targetSecureTagsProp
608
+ }
552
609
disabledProp , err := expandComputeFirewallPolicyRuleDisabled (d .Get ("disabled" ), d , config )
553
610
if err != nil {
554
611
return err
@@ -739,6 +796,8 @@ func flattenComputeFirewallPolicyRuleMatch(v interface{}, d *schema.ResourceData
739
796
flattenComputeFirewallPolicyRuleMatchDestThreatIntelligences (original ["destThreatIntelligences" ], d , config )
740
797
transformed ["src_threat_intelligences" ] =
741
798
flattenComputeFirewallPolicyRuleMatchSrcThreatIntelligences (original ["srcThreatIntelligences" ], d , config )
799
+ transformed ["src_secure_tags" ] =
800
+ flattenComputeFirewallPolicyRuleMatchSrcSecureTags (original ["srcSecureTags" ], d , config )
742
801
return []interface {}{transformed }
743
802
}
744
803
func flattenComputeFirewallPolicyRuleMatchSrcIpRanges (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
@@ -808,6 +867,33 @@ func flattenComputeFirewallPolicyRuleMatchSrcThreatIntelligences(v interface{},
808
867
return v
809
868
}
810
869
870
+ func flattenComputeFirewallPolicyRuleMatchSrcSecureTags (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
871
+ if v == nil {
872
+ return v
873
+ }
874
+ l := v .([]interface {})
875
+ transformed := make ([]interface {}, 0 , len (l ))
876
+ for _ , raw := range l {
877
+ original := raw .(map [string ]interface {})
878
+ if len (original ) < 1 {
879
+ // Do not include empty json objects coming back from the api
880
+ continue
881
+ }
882
+ transformed = append (transformed , map [string ]interface {}{
883
+ "name" : flattenComputeFirewallPolicyRuleMatchSrcSecureTagsName (original ["name" ], d , config ),
884
+ "state" : flattenComputeFirewallPolicyRuleMatchSrcSecureTagsState (original ["state" ], d , config ),
885
+ })
886
+ }
887
+ return transformed
888
+ }
889
+ func flattenComputeFirewallPolicyRuleMatchSrcSecureTagsName (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
890
+ return v
891
+ }
892
+
893
+ func flattenComputeFirewallPolicyRuleMatchSrcSecureTagsState (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
894
+ return v
895
+ }
896
+
811
897
func flattenComputeFirewallPolicyRuleAction (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
812
898
return v
813
899
}
@@ -853,6 +939,33 @@ func flattenComputeFirewallPolicyRuleTargetServiceAccounts(v interface{}, d *sch
853
939
return v
854
940
}
855
941
942
+ func flattenComputeFirewallPolicyRuleTargetSecureTags (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
943
+ if v == nil {
944
+ return v
945
+ }
946
+ l := v .([]interface {})
947
+ transformed := make ([]interface {}, 0 , len (l ))
948
+ for _ , raw := range l {
949
+ original := raw .(map [string ]interface {})
950
+ if len (original ) < 1 {
951
+ // Do not include empty json objects coming back from the api
952
+ continue
953
+ }
954
+ transformed = append (transformed , map [string ]interface {}{
955
+ "name" : flattenComputeFirewallPolicyRuleTargetSecureTagsName (original ["name" ], d , config ),
956
+ "state" : flattenComputeFirewallPolicyRuleTargetSecureTagsState (original ["state" ], d , config ),
957
+ })
958
+ }
959
+ return transformed
960
+ }
961
+ func flattenComputeFirewallPolicyRuleTargetSecureTagsName (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
962
+ return v
963
+ }
964
+
965
+ func flattenComputeFirewallPolicyRuleTargetSecureTagsState (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
966
+ return v
967
+ }
968
+
856
969
func flattenComputeFirewallPolicyRuleDisabled (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
857
970
return v
858
971
}
@@ -951,6 +1064,13 @@ func expandComputeFirewallPolicyRuleMatch(v interface{}, d tpgresource.Terraform
951
1064
transformed ["srcThreatIntelligences" ] = transformedSrcThreatIntelligences
952
1065
}
953
1066
1067
+ transformedSrcSecureTags , err := expandComputeFirewallPolicyRuleMatchSrcSecureTags (original ["src_secure_tags" ], d , config )
1068
+ if err != nil {
1069
+ return nil , err
1070
+ } else {
1071
+ transformed ["srcSecureTags" ] = transformedSrcSecureTags
1072
+ }
1073
+
954
1074
return transformed , nil
955
1075
}
956
1076
@@ -1031,6 +1151,43 @@ func expandComputeFirewallPolicyRuleMatchSrcThreatIntelligences(v interface{}, d
1031
1151
return v , nil
1032
1152
}
1033
1153
1154
+ func expandComputeFirewallPolicyRuleMatchSrcSecureTags (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1155
+ l := v .([]interface {})
1156
+ req := make ([]interface {}, 0 , len (l ))
1157
+ for _ , raw := range l {
1158
+ if raw == nil {
1159
+ continue
1160
+ }
1161
+ original := raw .(map [string ]interface {})
1162
+ transformed := make (map [string ]interface {})
1163
+
1164
+ transformedName , err := expandComputeFirewallPolicyRuleMatchSrcSecureTagsName (original ["name" ], d , config )
1165
+ if err != nil {
1166
+ return nil , err
1167
+ } else if val := reflect .ValueOf (transformedName ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1168
+ transformed ["name" ] = transformedName
1169
+ }
1170
+
1171
+ transformedState , err := expandComputeFirewallPolicyRuleMatchSrcSecureTagsState (original ["state" ], d , config )
1172
+ if err != nil {
1173
+ return nil , err
1174
+ } else if val := reflect .ValueOf (transformedState ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1175
+ transformed ["state" ] = transformedState
1176
+ }
1177
+
1178
+ req = append (req , transformed )
1179
+ }
1180
+ return req , nil
1181
+ }
1182
+
1183
+ func expandComputeFirewallPolicyRuleMatchSrcSecureTagsName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1184
+ return v , nil
1185
+ }
1186
+
1187
+ func expandComputeFirewallPolicyRuleMatchSrcSecureTagsState (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1188
+ return v , nil
1189
+ }
1190
+
1034
1191
func expandComputeFirewallPolicyRuleAction (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1035
1192
return v , nil
1036
1193
}
@@ -1059,6 +1216,43 @@ func expandComputeFirewallPolicyRuleTargetServiceAccounts(v interface{}, d tpgre
1059
1216
return v , nil
1060
1217
}
1061
1218
1219
+ func expandComputeFirewallPolicyRuleTargetSecureTags (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1220
+ l := v .([]interface {})
1221
+ req := make ([]interface {}, 0 , len (l ))
1222
+ for _ , raw := range l {
1223
+ if raw == nil {
1224
+ continue
1225
+ }
1226
+ original := raw .(map [string ]interface {})
1227
+ transformed := make (map [string ]interface {})
1228
+
1229
+ transformedName , err := expandComputeFirewallPolicyRuleTargetSecureTagsName (original ["name" ], d , config )
1230
+ if err != nil {
1231
+ return nil , err
1232
+ } else if val := reflect .ValueOf (transformedName ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1233
+ transformed ["name" ] = transformedName
1234
+ }
1235
+
1236
+ transformedState , err := expandComputeFirewallPolicyRuleTargetSecureTagsState (original ["state" ], d , config )
1237
+ if err != nil {
1238
+ return nil , err
1239
+ } else if val := reflect .ValueOf (transformedState ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1240
+ transformed ["state" ] = transformedState
1241
+ }
1242
+
1243
+ req = append (req , transformed )
1244
+ }
1245
+ return req , nil
1246
+ }
1247
+
1248
+ func expandComputeFirewallPolicyRuleTargetSecureTagsName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1249
+ return v , nil
1250
+ }
1251
+
1252
+ func expandComputeFirewallPolicyRuleTargetSecureTagsState (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1253
+ return v , nil
1254
+ }
1255
+
1062
1256
func expandComputeFirewallPolicyRuleDisabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1063
1257
return v , nil
1064
1258
}
0 commit comments