@@ -690,6 +690,78 @@ This field is only used with l4 load balancing.`,
690690 },
691691 },
692692 },
693+ "ha_policy" : {
694+ Type : schema .TypeList ,
695+ Optional : true ,
696+ Description : `Configures self-managed High Availability (HA) for External and Internal Protocol Forwarding.
697+ The backends of this regional backend service must only specify zonal network endpoint groups
698+ (NEGs) of type GCE_VM_IP. Note that haPolicy is not for load balancing, and therefore cannot
699+ be specified with sessionAffinity, connectionTrackingPolicy, and failoverPolicy. haPolicy
700+ requires customers to be responsible for tracking backend endpoint health and electing a
701+ leader among the healthy endpoints. Therefore, haPolicy cannot be specified with healthChecks.
702+ haPolicy can only be specified for External Passthrough Network Load Balancers and Internal
703+ Passthrough Network Load Balancers.` ,
704+ MaxItems : 1 ,
705+ Elem : & schema.Resource {
706+ Schema : map [string ]* schema.Schema {
707+ "fast_ip_move" : {
708+ Type : schema .TypeString ,
709+ Optional : true ,
710+ ForceNew : true ,
711+ ValidateFunc : verify .ValidateEnum ([]string {"DISABLED" , "GARP_RA" , "" }),
712+ Description : `Specifies whether fast IP move is enabled, and if so, the mechanism to achieve it.
713+ Supported values are:
714+
715+ * 'DISABLED': Fast IP Move is disabled. You can only use the haPolicy.leader API to
716+ update the leader.
717+
718+ * 'GARP_RA': Provides a method to very quickly define a new network endpoint as the
719+ leader. This method is faster than updating the leader using the
720+ haPolicy.leader API. Fast IP move works as follows: The VM hosting the
721+ network endpoint that should become the new leader sends either a
722+ Gratuitous ARP (GARP) packet (IPv4) or an ICMPv6 Router Advertisement(RA)
723+ packet (IPv6). Google Cloud immediately but temporarily associates the
724+ forwarding rule IP address with that VM, and both new and in-flight packets
725+ are quickly delivered to that VM. Possible values: ["DISABLED", "GARP_RA"]` ,
726+ },
727+ "leader" : {
728+ Type : schema .TypeList ,
729+ Optional : true ,
730+ Description : `Selects one of the network endpoints attached to the backend NEGs of this service as the
731+ active endpoint (the leader) that receives all traffic.` ,
732+ MaxItems : 1 ,
733+ Elem : & schema.Resource {
734+ Schema : map [string ]* schema.Schema {
735+ "backend_group" : {
736+ Type : schema .TypeString ,
737+ Optional : true ,
738+ DiffSuppressFunc : tpgresource .CompareSelfLinkOrResourceName ,
739+ Description : `A fully-qualified URL of the zonal Network Endpoint Group (NEG) that the leader is
740+ attached to.` ,
741+ },
742+ "network_endpoint" : {
743+ Type : schema .TypeList ,
744+ Optional : true ,
745+ Description : `The network endpoint within the leader.backendGroup that is designated as the leader.` ,
746+ MaxItems : 1 ,
747+ Elem : & schema.Resource {
748+ Schema : map [string ]* schema.Schema {
749+ "instance" : {
750+ Type : schema .TypeString ,
751+ Optional : true ,
752+ Description : `The name of the VM instance of the leader network endpoint. The instance must
753+ already be attached to the NEG specified in the haPolicy.leader.backendGroup.` ,
754+ },
755+ },
756+ },
757+ },
758+ },
759+ },
760+ },
761+ },
762+ },
763+ ConflictsWith : []string {"session_affinity" , "connection_tracking_policy" , "failover_policy" , "health_checks" },
764+ },
693765 "health_checks" : {
694766 Type : schema .TypeSet ,
695767 Optional : true ,
@@ -1534,6 +1606,12 @@ func resourceComputeRegionBackendServiceCreate(d *schema.ResourceData, meta inte
15341606 } else if v , ok := d .GetOkExists ("dynamic_forwarding" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (dynamicForwardingProp )) && (ok || ! reflect .DeepEqual (v , dynamicForwardingProp )) {
15351607 obj ["dynamicForwarding" ] = dynamicForwardingProp
15361608 }
1609+ haPolicyProp , err := expandComputeRegionBackendServiceHaPolicy (d .Get ("ha_policy" ), d , config )
1610+ if err != nil {
1611+ return err
1612+ } else if v , ok := d .GetOkExists ("ha_policy" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (haPolicyProp )) && (ok || ! reflect .DeepEqual (v , haPolicyProp )) {
1613+ obj ["haPolicy" ] = haPolicyProp
1614+ }
15371615 regionProp , err := expandComputeRegionBackendServiceRegion (d .Get ("region" ), d , config )
15381616 if err != nil {
15391617 return err
@@ -1799,6 +1877,9 @@ func resourceComputeRegionBackendServiceRead(d *schema.ResourceData, meta interf
17991877 if err := d .Set ("dynamic_forwarding" , flattenComputeRegionBackendServiceDynamicForwarding (res ["dynamicForwarding" ], d , config )); err != nil {
18001878 return fmt .Errorf ("Error reading RegionBackendService: %s" , err )
18011879 }
1880+ if err := d .Set ("ha_policy" , flattenComputeRegionBackendServiceHaPolicy (res ["haPolicy" ], d , config )); err != nil {
1881+ return fmt .Errorf ("Error reading RegionBackendService: %s" , err )
1882+ }
18021883 if err := d .Set ("region" , flattenComputeRegionBackendServiceRegion (res ["region" ], d , config )); err != nil {
18031884 return fmt .Errorf ("Error reading RegionBackendService: %s" , err )
18041885 }
@@ -1993,6 +2074,12 @@ func resourceComputeRegionBackendServiceUpdate(d *schema.ResourceData, meta inte
19932074 } else if v , ok := d .GetOkExists ("dynamic_forwarding" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , dynamicForwardingProp )) {
19942075 obj ["dynamicForwarding" ] = dynamicForwardingProp
19952076 }
2077+ haPolicyProp , err := expandComputeRegionBackendServiceHaPolicy (d .Get ("ha_policy" ), d , config )
2078+ if err != nil {
2079+ return err
2080+ } else if v , ok := d .GetOkExists ("ha_policy" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , haPolicyProp )) {
2081+ obj ["haPolicy" ] = haPolicyProp
2082+ }
19962083 regionProp , err := expandComputeRegionBackendServiceRegion (d .Get ("region" ), d , config )
19972084 if err != nil {
19982085 return err
@@ -3575,6 +3662,64 @@ func flattenComputeRegionBackendServiceDynamicForwardingIpPortSelectionEnabled(v
35753662 return v
35763663}
35773664
3665+ func flattenComputeRegionBackendServiceHaPolicy (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3666+ if v == nil {
3667+ return nil
3668+ }
3669+ original := v .(map [string ]interface {})
3670+ if len (original ) == 0 {
3671+ return nil
3672+ }
3673+ transformed := make (map [string ]interface {})
3674+ transformed ["fast_ip_move" ] =
3675+ flattenComputeRegionBackendServiceHaPolicyFastIPMove (original ["fastIPMove" ], d , config )
3676+ transformed ["leader" ] =
3677+ flattenComputeRegionBackendServiceHaPolicyLeader (original ["leader" ], d , config )
3678+ return []interface {}{transformed }
3679+ }
3680+ func flattenComputeRegionBackendServiceHaPolicyFastIPMove (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3681+ return v
3682+ }
3683+
3684+ func flattenComputeRegionBackendServiceHaPolicyLeader (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3685+ if v == nil {
3686+ return nil
3687+ }
3688+ original := v .(map [string ]interface {})
3689+ if len (original ) == 0 {
3690+ return nil
3691+ }
3692+ transformed := make (map [string ]interface {})
3693+ transformed ["backend_group" ] =
3694+ flattenComputeRegionBackendServiceHaPolicyLeaderBackendGroup (original ["backendGroup" ], d , config )
3695+ transformed ["network_endpoint" ] =
3696+ flattenComputeRegionBackendServiceHaPolicyLeaderNetworkEndpoint (original ["networkEndpoint" ], d , config )
3697+ return []interface {}{transformed }
3698+ }
3699+ func flattenComputeRegionBackendServiceHaPolicyLeaderBackendGroup (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3700+ if v == nil {
3701+ return v
3702+ }
3703+ return tpgresource .ConvertSelfLinkToV1 (v .(string ))
3704+ }
3705+
3706+ func flattenComputeRegionBackendServiceHaPolicyLeaderNetworkEndpoint (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3707+ if v == nil {
3708+ return nil
3709+ }
3710+ original := v .(map [string ]interface {})
3711+ if len (original ) == 0 {
3712+ return nil
3713+ }
3714+ transformed := make (map [string ]interface {})
3715+ transformed ["instance" ] =
3716+ flattenComputeRegionBackendServiceHaPolicyLeaderNetworkEndpointInstance (original ["instance" ], d , config )
3717+ return []interface {}{transformed }
3718+ }
3719+ func flattenComputeRegionBackendServiceHaPolicyLeaderNetworkEndpointInstance (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3720+ return v
3721+ }
3722+
35783723func flattenComputeRegionBackendServiceRegion (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
35793724 if v == nil {
35803725 return v
@@ -4904,6 +5049,89 @@ func expandComputeRegionBackendServiceDynamicForwardingIpPortSelectionEnabled(v
49045049 return v , nil
49055050}
49065051
5052+ func expandComputeRegionBackendServiceHaPolicy (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5053+ l := v .([]interface {})
5054+ if len (l ) == 0 || l [0 ] == nil {
5055+ return nil , nil
5056+ }
5057+ raw := l [0 ]
5058+ original := raw .(map [string ]interface {})
5059+ transformed := make (map [string ]interface {})
5060+
5061+ transformedFastIPMove , err := expandComputeRegionBackendServiceHaPolicyFastIPMove (original ["fast_ip_move" ], d , config )
5062+ if err != nil {
5063+ return nil , err
5064+ } else if val := reflect .ValueOf (transformedFastIPMove ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5065+ transformed ["fastIPMove" ] = transformedFastIPMove
5066+ }
5067+
5068+ transformedLeader , err := expandComputeRegionBackendServiceHaPolicyLeader (original ["leader" ], d , config )
5069+ if err != nil {
5070+ return nil , err
5071+ } else if val := reflect .ValueOf (transformedLeader ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5072+ transformed ["leader" ] = transformedLeader
5073+ }
5074+
5075+ return transformed , nil
5076+ }
5077+
5078+ func expandComputeRegionBackendServiceHaPolicyFastIPMove (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5079+ return v , nil
5080+ }
5081+
5082+ func expandComputeRegionBackendServiceHaPolicyLeader (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5083+ l := v .([]interface {})
5084+ if len (l ) == 0 || l [0 ] == nil {
5085+ return nil , nil
5086+ }
5087+ raw := l [0 ]
5088+ original := raw .(map [string ]interface {})
5089+ transformed := make (map [string ]interface {})
5090+
5091+ transformedBackendGroup , err := expandComputeRegionBackendServiceHaPolicyLeaderBackendGroup (original ["backend_group" ], d , config )
5092+ if err != nil {
5093+ return nil , err
5094+ } else if val := reflect .ValueOf (transformedBackendGroup ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5095+ transformed ["backendGroup" ] = transformedBackendGroup
5096+ }
5097+
5098+ transformedNetworkEndpoint , err := expandComputeRegionBackendServiceHaPolicyLeaderNetworkEndpoint (original ["network_endpoint" ], d , config )
5099+ if err != nil {
5100+ return nil , err
5101+ } else if val := reflect .ValueOf (transformedNetworkEndpoint ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5102+ transformed ["networkEndpoint" ] = transformedNetworkEndpoint
5103+ }
5104+
5105+ return transformed , nil
5106+ }
5107+
5108+ func expandComputeRegionBackendServiceHaPolicyLeaderBackendGroup (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5109+ return v , nil
5110+ }
5111+
5112+ func expandComputeRegionBackendServiceHaPolicyLeaderNetworkEndpoint (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5113+ l := v .([]interface {})
5114+ if len (l ) == 0 || l [0 ] == nil {
5115+ return nil , nil
5116+ }
5117+ raw := l [0 ]
5118+ original := raw .(map [string ]interface {})
5119+ transformed := make (map [string ]interface {})
5120+
5121+ transformedInstance , err := expandComputeRegionBackendServiceHaPolicyLeaderNetworkEndpointInstance (original ["instance" ], d , config )
5122+ if err != nil {
5123+ return nil , err
5124+ } else if val := reflect .ValueOf (transformedInstance ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5125+ transformed ["instance" ] = transformedInstance
5126+ }
5127+
5128+ return transformed , nil
5129+ }
5130+
5131+ func expandComputeRegionBackendServiceHaPolicyLeaderNetworkEndpointInstance (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5132+ return v , nil
5133+ }
5134+
49075135func expandComputeRegionBackendServiceRegion (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
49085136 f , err := tpgresource .ParseGlobalFieldValue ("regions" , v .(string ), "project" , d , config , true )
49095137 if err != nil {
0 commit comments