@@ -197,6 +197,26 @@ Example inputs include: ["22"], ["80","443"], and ["12345-12349"].`,
197197 Type : schema .TypeString ,
198198 },
199199 },
200+ "src_secure_tags" : {
201+ Type : schema .TypeList ,
202+ Optional : true ,
203+ 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.` ,
204+ Elem : & schema.Resource {
205+ Schema : map [string ]* schema.Schema {
206+ "name" : {
207+ Type : schema .TypeString ,
208+ Optional : true ,
209+ DiffSuppressFunc : tpgresource .CompareSelfLinkOrResourceName ,
210+ Description : `Name of the secure tag, created with TagManager's TagValue API.` ,
211+ },
212+ "state" : {
213+ Type : schema .TypeString ,
214+ Computed : true ,
215+ Description : `State of the secure tag, either EFFECTIVE or INEFFECTIVE. A secure tag is INEFFECTIVE when it is deleted or its network is deleted.` ,
216+ },
217+ },
218+ },
219+ },
200220 "src_threat_intelligences" : {
201221 Type : schema .TypeList ,
202222 Optional : true ,
@@ -254,6 +274,28 @@ If this field is left blank, all VMs within the organization will receive the ru
254274 Type : schema .TypeString ,
255275 },
256276 },
277+ "target_secure_tags" : {
278+ Type : schema .TypeList ,
279+ Optional : true ,
280+ Description : `A list of secure tags that controls which instances the firewall rule applies to.
281+ 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.
282+ 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.` ,
283+ Elem : & schema.Resource {
284+ Schema : map [string ]* schema.Schema {
285+ "name" : {
286+ Type : schema .TypeString ,
287+ Optional : true ,
288+ DiffSuppressFunc : tpgresource .CompareSelfLinkOrResourceName ,
289+ Description : `Name of the secure tag, created with TagManager's TagValue API.` ,
290+ },
291+ "state" : {
292+ Type : schema .TypeString ,
293+ Computed : true ,
294+ Description : `State of the secure tag, either EFFECTIVE or INEFFECTIVE. A secure tag is INEFFECTIVE when it is deleted or its network is deleted.` ,
295+ },
296+ },
297+ },
298+ },
257299 "target_service_accounts" : {
258300 Type : schema .TypeList ,
259301 Optional : true ,
@@ -356,6 +398,12 @@ func resourceComputeFirewallPolicyRuleCreate(d *schema.ResourceData, meta interf
356398 } else if v , ok := d .GetOkExists ("target_service_accounts" ); ok || ! reflect .DeepEqual (v , targetServiceAccountsProp ) {
357399 obj ["targetServiceAccounts" ] = targetServiceAccountsProp
358400 }
401+ targetSecureTagsProp , err := expandComputeFirewallPolicyRuleTargetSecureTags (d .Get ("target_secure_tags" ), d , config )
402+ if err != nil {
403+ return err
404+ } else if v , ok := d .GetOkExists ("target_secure_tags" ); ok || ! reflect .DeepEqual (v , targetSecureTagsProp ) {
405+ obj ["targetSecureTags" ] = targetSecureTagsProp
406+ }
359407 disabledProp , err := expandComputeFirewallPolicyRuleDisabled (d .Get ("disabled" ), d , config )
360408 if err != nil {
361409 return err
@@ -492,6 +540,9 @@ func resourceComputeFirewallPolicyRuleRead(d *schema.ResourceData, meta interfac
492540 if err := d .Set ("target_service_accounts" , flattenComputeFirewallPolicyRuleTargetServiceAccounts (res ["targetServiceAccounts" ], d , config )); err != nil {
493541 return fmt .Errorf ("Error reading FirewallPolicyRule: %s" , err )
494542 }
543+ if err := d .Set ("target_secure_tags" , flattenComputeFirewallPolicyRuleTargetSecureTags (res ["targetSecureTags" ], d , config )); err != nil {
544+ return fmt .Errorf ("Error reading FirewallPolicyRule: %s" , err )
545+ }
495546 if err := d .Set ("disabled" , flattenComputeFirewallPolicyRuleDisabled (res ["disabled" ], d , config )); err != nil {
496547 return fmt .Errorf ("Error reading FirewallPolicyRule: %s" , err )
497548 }
@@ -569,6 +620,12 @@ func resourceComputeFirewallPolicyRuleUpdate(d *schema.ResourceData, meta interf
569620 } else if v , ok := d .GetOkExists ("target_service_accounts" ); ok || ! reflect .DeepEqual (v , targetServiceAccountsProp ) {
570621 obj ["targetServiceAccounts" ] = targetServiceAccountsProp
571622 }
623+ targetSecureTagsProp , err := expandComputeFirewallPolicyRuleTargetSecureTags (d .Get ("target_secure_tags" ), d , config )
624+ if err != nil {
625+ return err
626+ } else if v , ok := d .GetOkExists ("target_secure_tags" ); ok || ! reflect .DeepEqual (v , targetSecureTagsProp ) {
627+ obj ["targetSecureTags" ] = targetSecureTagsProp
628+ }
572629 disabledProp , err := expandComputeFirewallPolicyRuleDisabled (d .Get ("disabled" ), d , config )
573630 if err != nil {
574631 return err
@@ -765,6 +822,8 @@ func flattenComputeFirewallPolicyRuleMatch(v interface{}, d *schema.ResourceData
765822 flattenComputeFirewallPolicyRuleMatchDestThreatIntelligences (original ["destThreatIntelligences" ], d , config )
766823 transformed ["src_threat_intelligences" ] =
767824 flattenComputeFirewallPolicyRuleMatchSrcThreatIntelligences (original ["srcThreatIntelligences" ], d , config )
825+ transformed ["src_secure_tags" ] =
826+ flattenComputeFirewallPolicyRuleMatchSrcSecureTags (original ["srcSecureTags" ], d , config )
768827 return []interface {}{transformed }
769828}
770829func flattenComputeFirewallPolicyRuleMatchSrcIpRanges (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
@@ -846,6 +905,33 @@ func flattenComputeFirewallPolicyRuleMatchSrcThreatIntelligences(v interface{},
846905 return v
847906}
848907
908+ func flattenComputeFirewallPolicyRuleMatchSrcSecureTags (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
909+ if v == nil {
910+ return v
911+ }
912+ l := v .([]interface {})
913+ transformed := make ([]interface {}, 0 , len (l ))
914+ for _ , raw := range l {
915+ original := raw .(map [string ]interface {})
916+ if len (original ) < 1 {
917+ // Do not include empty json objects coming back from the api
918+ continue
919+ }
920+ transformed = append (transformed , map [string ]interface {}{
921+ "name" : flattenComputeFirewallPolicyRuleMatchSrcSecureTagsName (original ["name" ], d , config ),
922+ "state" : flattenComputeFirewallPolicyRuleMatchSrcSecureTagsState (original ["state" ], d , config ),
923+ })
924+ }
925+ return transformed
926+ }
927+ func flattenComputeFirewallPolicyRuleMatchSrcSecureTagsName (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
928+ return v
929+ }
930+
931+ func flattenComputeFirewallPolicyRuleMatchSrcSecureTagsState (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
932+ return v
933+ }
934+
849935func flattenComputeFirewallPolicyRuleAction (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
850936 return v
851937}
@@ -891,6 +977,33 @@ func flattenComputeFirewallPolicyRuleTargetServiceAccounts(v interface{}, d *sch
891977 return v
892978}
893979
980+ func flattenComputeFirewallPolicyRuleTargetSecureTags (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
981+ if v == nil {
982+ return v
983+ }
984+ l := v .([]interface {})
985+ transformed := make ([]interface {}, 0 , len (l ))
986+ for _ , raw := range l {
987+ original := raw .(map [string ]interface {})
988+ if len (original ) < 1 {
989+ // Do not include empty json objects coming back from the api
990+ continue
991+ }
992+ transformed = append (transformed , map [string ]interface {}{
993+ "name" : flattenComputeFirewallPolicyRuleTargetSecureTagsName (original ["name" ], d , config ),
994+ "state" : flattenComputeFirewallPolicyRuleTargetSecureTagsState (original ["state" ], d , config ),
995+ })
996+ }
997+ return transformed
998+ }
999+ func flattenComputeFirewallPolicyRuleTargetSecureTagsName (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1000+ return v
1001+ }
1002+
1003+ func flattenComputeFirewallPolicyRuleTargetSecureTagsState (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1004+ return v
1005+ }
1006+
8941007func flattenComputeFirewallPolicyRuleDisabled (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
8951008 return v
8961009}
@@ -1010,6 +1123,13 @@ func expandComputeFirewallPolicyRuleMatch(v interface{}, d tpgresource.Terraform
10101123 transformed ["srcThreatIntelligences" ] = transformedSrcThreatIntelligences
10111124 }
10121125
1126+ transformedSrcSecureTags , err := expandComputeFirewallPolicyRuleMatchSrcSecureTags (original ["src_secure_tags" ], d , config )
1127+ if err != nil {
1128+ return nil , err
1129+ } else {
1130+ transformed ["srcSecureTags" ] = transformedSrcSecureTags
1131+ }
1132+
10131133 return transformed , nil
10141134}
10151135
@@ -1102,6 +1222,43 @@ func expandComputeFirewallPolicyRuleMatchSrcThreatIntelligences(v interface{}, d
11021222 return v , nil
11031223}
11041224
1225+ func expandComputeFirewallPolicyRuleMatchSrcSecureTags (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1226+ l := v .([]interface {})
1227+ req := make ([]interface {}, 0 , len (l ))
1228+ for _ , raw := range l {
1229+ if raw == nil {
1230+ continue
1231+ }
1232+ original := raw .(map [string ]interface {})
1233+ transformed := make (map [string ]interface {})
1234+
1235+ transformedName , err := expandComputeFirewallPolicyRuleMatchSrcSecureTagsName (original ["name" ], d , config )
1236+ if err != nil {
1237+ return nil , err
1238+ } else if val := reflect .ValueOf (transformedName ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1239+ transformed ["name" ] = transformedName
1240+ }
1241+
1242+ transformedState , err := expandComputeFirewallPolicyRuleMatchSrcSecureTagsState (original ["state" ], d , config )
1243+ if err != nil {
1244+ return nil , err
1245+ } else if val := reflect .ValueOf (transformedState ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1246+ transformed ["state" ] = transformedState
1247+ }
1248+
1249+ req = append (req , transformed )
1250+ }
1251+ return req , nil
1252+ }
1253+
1254+ func expandComputeFirewallPolicyRuleMatchSrcSecureTagsName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1255+ return v , nil
1256+ }
1257+
1258+ func expandComputeFirewallPolicyRuleMatchSrcSecureTagsState (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1259+ return v , nil
1260+ }
1261+
11051262func expandComputeFirewallPolicyRuleAction (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
11061263 return v , nil
11071264}
@@ -1130,6 +1287,43 @@ func expandComputeFirewallPolicyRuleTargetServiceAccounts(v interface{}, d tpgre
11301287 return v , nil
11311288}
11321289
1290+ func expandComputeFirewallPolicyRuleTargetSecureTags (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1291+ l := v .([]interface {})
1292+ req := make ([]interface {}, 0 , len (l ))
1293+ for _ , raw := range l {
1294+ if raw == nil {
1295+ continue
1296+ }
1297+ original := raw .(map [string ]interface {})
1298+ transformed := make (map [string ]interface {})
1299+
1300+ transformedName , err := expandComputeFirewallPolicyRuleTargetSecureTagsName (original ["name" ], d , config )
1301+ if err != nil {
1302+ return nil , err
1303+ } else if val := reflect .ValueOf (transformedName ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1304+ transformed ["name" ] = transformedName
1305+ }
1306+
1307+ transformedState , err := expandComputeFirewallPolicyRuleTargetSecureTagsState (original ["state" ], d , config )
1308+ if err != nil {
1309+ return nil , err
1310+ } else if val := reflect .ValueOf (transformedState ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1311+ transformed ["state" ] = transformedState
1312+ }
1313+
1314+ req = append (req , transformed )
1315+ }
1316+ return req , nil
1317+ }
1318+
1319+ func expandComputeFirewallPolicyRuleTargetSecureTagsName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1320+ return v , nil
1321+ }
1322+
1323+ func expandComputeFirewallPolicyRuleTargetSecureTagsState (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1324+ return v , nil
1325+ }
1326+
11331327func expandComputeFirewallPolicyRuleDisabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
11341328 return v , nil
11351329}
0 commit comments