@@ -400,6 +400,13 @@ can be specified as values, and you cannot specify a status code more than once.
400
400
},
401
401
},
402
402
},
403
+ "request_coalescing" : {
404
+ Type : schema .TypeBool ,
405
+ Computed : true ,
406
+ Optional : true ,
407
+ Description : `If true then Cloud CDN will combine multiple concurrent cache fill requests into a small number of requests
408
+ to the origin.` ,
409
+ },
403
410
"serve_while_stale" : {
404
411
Type : schema .TypeInt ,
405
412
Computed : true ,
@@ -890,6 +897,25 @@ If logging is enabled, logs will be exported to Stackdriver.`,
890
897
Description : `Whether to enable logging for the load balancer traffic served by this backend service.` ,
891
898
AtLeastOneOf : []string {"log_config.0.enable" , "log_config.0.sample_rate" },
892
899
},
900
+ "optional_fields" : {
901
+ Type : schema .TypeList ,
902
+ Optional : true ,
903
+ Description : `This field can only be specified if logging is enabled for this backend service and "logConfig.optionalMode"
904
+ was set to CUSTOM. Contains a list of optional fields you want to include in the logs.
905
+ For example: serverInstance, serverGkeDetails.cluster, serverGkeDetails.pod.podNamespace` ,
906
+ Elem : & schema.Schema {
907
+ Type : schema .TypeString ,
908
+ },
909
+ },
910
+ "optional_mode" : {
911
+ Type : schema .TypeString ,
912
+ Computed : true ,
913
+ Optional : true ,
914
+ ValidateFunc : verify .ValidateEnum ([]string {"INCLUDE_ALL_OPTIONAL" , "EXCLUDE_ALL_OPTIONAL" , "CUSTOM" , "" }),
915
+ Description : `Specifies the optional logging mode for the load balancer traffic.
916
+ Supported values: INCLUDE_ALL_OPTIONAL, EXCLUDE_ALL_OPTIONAL, CUSTOM. Possible values: ["INCLUDE_ALL_OPTIONAL", "EXCLUDE_ALL_OPTIONAL", "CUSTOM"]` ,
917
+ AtLeastOneOf : []string {"log_config.0.enable" , "log_config.0.sample_rate" , "log_config.0.optional_mode" },
918
+ },
893
919
"sample_rate" : {
894
920
Type : schema .TypeFloat ,
895
921
Optional : true ,
@@ -904,6 +930,33 @@ The default value is 1.0.`,
904
930
},
905
931
},
906
932
},
933
+ "max_stream_duration" : {
934
+ Type : schema .TypeList ,
935
+ Optional : true ,
936
+ Description : `Specifies the default maximum duration (timeout) for streams to this service. Duration is computed from the
937
+ beginning of the stream until the response has been completely processed, including all retries. A stream that
938
+ does not complete in this duration is closed.
939
+ If not specified, there will be no timeout limit, i.e. the maximum duration is infinite.
940
+ This value can be overridden in the PathMatcher configuration of the UrlMap that references this backend service.
941
+ This field is only allowed when the loadBalancingScheme of the backend service is INTERNAL_SELF_MANAGED.` ,
942
+ MaxItems : 1 ,
943
+ Elem : & schema.Resource {
944
+ Schema : map [string ]* schema.Schema {
945
+ "seconds" : {
946
+ Type : schema .TypeString ,
947
+ Required : true ,
948
+ Description : `Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. (int64 format)` ,
949
+ },
950
+ "nanos" : {
951
+ Type : schema .TypeInt ,
952
+ Optional : true ,
953
+ Description : `Span of time that's a fraction of a second at nanosecond resolution.
954
+ Durations less than one second are represented with a 0 seconds field and a positive nanos field.
955
+ Must be from 0 to 999,999,999 inclusive.` ,
956
+ },
957
+ },
958
+ },
959
+ },
907
960
"outlier_detection" : {
908
961
Type : schema .TypeList ,
909
962
Optional : true ,
@@ -1398,6 +1451,17 @@ either maxRate or maxRatePerInstance must be set.`,
1398
1451
Description : `Used when balancingMode is UTILIZATION. This ratio defines the
1399
1452
CPU utilization target for the group. Valid range is [0.0, 1.0].` ,
1400
1453
},
1454
+ "preference" : {
1455
+ Type : schema .TypeString ,
1456
+ Optional : true ,
1457
+ ValidateFunc : verify .ValidateEnum ([]string {"PREFERRED" , "DEFAULT" , "" }),
1458
+ Description : `This field indicates whether this backend should be fully utilized before sending traffic to backends
1459
+ with default preference. This field cannot be set when loadBalancingScheme is set to 'EXTERNAL'. The possible values are:
1460
+ - PREFERRED: Backends with this preference level will be filled up to their capacity limits first,
1461
+ based on RTT.
1462
+ - DEFAULT: If preferred backends don't have enough capacity, backends in this layer would be used and
1463
+ traffic would be assigned based on the load balancing algorithm you use. This is the default Possible values: ["PREFERRED", "DEFAULT"]` ,
1464
+ },
1401
1465
},
1402
1466
}
1403
1467
}
@@ -1596,6 +1660,12 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{
1596
1660
} else if v , ok := d .GetOkExists ("service_lb_policy" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (serviceLbPolicyProp )) && (ok || ! reflect .DeepEqual (v , serviceLbPolicyProp )) {
1597
1661
obj ["serviceLbPolicy" ] = serviceLbPolicyProp
1598
1662
}
1663
+ maxStreamDurationProp , err := expandComputeBackendServiceMaxStreamDuration (d .Get ("max_stream_duration" ), d , config )
1664
+ if err != nil {
1665
+ return err
1666
+ } else if v , ok := d .GetOkExists ("max_stream_duration" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (maxStreamDurationProp )) && (ok || ! reflect .DeepEqual (v , maxStreamDurationProp )) {
1667
+ obj ["maxStreamDuration" ] = maxStreamDurationProp
1668
+ }
1599
1669
1600
1670
obj , err = resourceComputeBackendServiceEncoder (d , meta , obj )
1601
1671
if err != nil {
@@ -1862,6 +1932,9 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{})
1862
1932
if err := d .Set ("service_lb_policy" , flattenComputeBackendServiceServiceLbPolicy (res ["serviceLbPolicy" ], d , config )); err != nil {
1863
1933
return fmt .Errorf ("Error reading BackendService: %s" , err )
1864
1934
}
1935
+ if err := d .Set ("max_stream_duration" , flattenComputeBackendServiceMaxStreamDuration (res ["maxStreamDuration" ], d , config )); err != nil {
1936
+ return fmt .Errorf ("Error reading BackendService: %s" , err )
1937
+ }
1865
1938
if err := d .Set ("self_link" , tpgresource .ConvertSelfLinkToV1 (res ["selfLink" ].(string ))); err != nil {
1866
1939
return fmt .Errorf ("Error reading BackendService: %s" , err )
1867
1940
}
@@ -2071,6 +2144,12 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{
2071
2144
} else if v , ok := d .GetOkExists ("service_lb_policy" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , serviceLbPolicyProp )) {
2072
2145
obj ["serviceLbPolicy" ] = serviceLbPolicyProp
2073
2146
}
2147
+ maxStreamDurationProp , err := expandComputeBackendServiceMaxStreamDuration (d .Get ("max_stream_duration" ), d , config )
2148
+ if err != nil {
2149
+ return err
2150
+ } else if v , ok := d .GetOkExists ("max_stream_duration" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , maxStreamDurationProp )) {
2151
+ obj ["maxStreamDuration" ] = maxStreamDurationProp
2152
+ }
2074
2153
2075
2154
obj , err = resourceComputeBackendServiceEncoder (d , meta , obj )
2076
2155
if err != nil {
@@ -2264,6 +2343,7 @@ func flattenComputeBackendServiceBackend(v interface{}, d *schema.ResourceData,
2264
2343
transformed .Add (map [string ]interface {}{
2265
2344
"balancing_mode" : flattenComputeBackendServiceBackendBalancingMode (original ["balancingMode" ], d , config ),
2266
2345
"capacity_scaler" : flattenComputeBackendServiceBackendCapacityScaler (original ["capacityScaler" ], d , config ),
2346
+ "preference" : flattenComputeBackendServiceBackendPreference (original ["preference" ], d , config ),
2267
2347
"description" : flattenComputeBackendServiceBackendDescription (original ["description" ], d , config ),
2268
2348
"group" : flattenComputeBackendServiceBackendGroup (original ["group" ], d , config ),
2269
2349
"max_connections" : flattenComputeBackendServiceBackendMaxConnections (original ["maxConnections" ], d , config ),
@@ -2286,6 +2366,10 @@ func flattenComputeBackendServiceBackendCapacityScaler(v interface{}, d *schema.
2286
2366
return v
2287
2367
}
2288
2368
2369
+ func flattenComputeBackendServiceBackendPreference (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2370
+ return v
2371
+ }
2372
+
2289
2373
func flattenComputeBackendServiceBackendDescription (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2290
2374
return v
2291
2375
}
@@ -2640,6 +2724,8 @@ func flattenComputeBackendServiceCdnPolicy(v interface{}, d *schema.ResourceData
2640
2724
return nil
2641
2725
}
2642
2726
transformed := make (map [string ]interface {})
2727
+ transformed ["request_coalescing" ] =
2728
+ flattenComputeBackendServiceCdnPolicyRequestCoalescing (original ["requestCoalescing" ], d , config )
2643
2729
transformed ["cache_key_policy" ] =
2644
2730
flattenComputeBackendServiceCdnPolicyCacheKeyPolicy (original ["cacheKeyPolicy" ], d , config )
2645
2731
transformed ["signed_url_cache_max_age_sec" ] =
@@ -2662,6 +2748,10 @@ func flattenComputeBackendServiceCdnPolicy(v interface{}, d *schema.ResourceData
2662
2748
flattenComputeBackendServiceCdnPolicyBypassCacheOnRequestHeaders (original ["bypassCacheOnRequestHeaders" ], d , config )
2663
2749
return []interface {}{transformed }
2664
2750
}
2751
+ func flattenComputeBackendServiceCdnPolicyRequestCoalescing (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2752
+ return v
2753
+ }
2754
+
2665
2755
func flattenComputeBackendServiceCdnPolicyCacheKeyPolicy (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2666
2756
if v == nil {
2667
2757
return nil
@@ -3581,6 +3671,10 @@ func flattenComputeBackendServiceLogConfig(v interface{}, d *schema.ResourceData
3581
3671
flattenComputeBackendServiceLogConfigEnable (original ["enable" ], d , config )
3582
3672
transformed ["sample_rate" ] =
3583
3673
flattenComputeBackendServiceLogConfigSampleRate (original ["sampleRate" ], d , config )
3674
+ transformed ["optional_mode" ] =
3675
+ flattenComputeBackendServiceLogConfigOptionalMode (original ["optionalMode" ], d , config )
3676
+ transformed ["optional_fields" ] =
3677
+ flattenComputeBackendServiceLogConfigOptionalFields (original ["optionalFields" ], d , config )
3584
3678
return []interface {}{transformed }
3585
3679
}
3586
3680
func flattenComputeBackendServiceLogConfigEnable (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
@@ -3591,10 +3685,54 @@ func flattenComputeBackendServiceLogConfigSampleRate(v interface{}, d *schema.Re
3591
3685
return v
3592
3686
}
3593
3687
3688
+ func flattenComputeBackendServiceLogConfigOptionalMode (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3689
+ return v
3690
+ }
3691
+
3692
+ func flattenComputeBackendServiceLogConfigOptionalFields (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3693
+ return v
3694
+ }
3695
+
3594
3696
func flattenComputeBackendServiceServiceLbPolicy (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3595
3697
return v
3596
3698
}
3597
3699
3700
+ func flattenComputeBackendServiceMaxStreamDuration (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3701
+ if v == nil {
3702
+ return nil
3703
+ }
3704
+ original := v .(map [string ]interface {})
3705
+ if len (original ) == 0 {
3706
+ return nil
3707
+ }
3708
+ transformed := make (map [string ]interface {})
3709
+ transformed ["seconds" ] =
3710
+ flattenComputeBackendServiceMaxStreamDurationSeconds (original ["seconds" ], d , config )
3711
+ transformed ["nanos" ] =
3712
+ flattenComputeBackendServiceMaxStreamDurationNanos (original ["nanos" ], d , config )
3713
+ return []interface {}{transformed }
3714
+ }
3715
+ func flattenComputeBackendServiceMaxStreamDurationSeconds (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3716
+ return v
3717
+ }
3718
+
3719
+ func flattenComputeBackendServiceMaxStreamDurationNanos (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
3720
+ // Handles the string fixed64 format
3721
+ if strVal , ok := v .(string ); ok {
3722
+ if intVal , err := tpgresource .StringToFixed64 (strVal ); err == nil {
3723
+ return intVal
3724
+ }
3725
+ }
3726
+
3727
+ // number values are represented as float64
3728
+ if floatVal , ok := v .(float64 ); ok {
3729
+ intVal := int (floatVal )
3730
+ return intVal
3731
+ }
3732
+
3733
+ return v // let terraform core handle it otherwise
3734
+ }
3735
+
3598
3736
func expandComputeBackendServiceAffinityCookieTtlSec (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
3599
3737
return v , nil
3600
3738
}
@@ -3624,6 +3762,13 @@ func expandComputeBackendServiceBackend(v interface{}, d tpgresource.TerraformRe
3624
3762
transformed ["capacityScaler" ] = transformedCapacityScaler
3625
3763
}
3626
3764
3765
+ transformedPreference , err := expandComputeBackendServiceBackendPreference (original ["preference" ], d , config )
3766
+ if err != nil {
3767
+ return nil , err
3768
+ } else if val := reflect .ValueOf (transformedPreference ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
3769
+ transformed ["preference" ] = transformedPreference
3770
+ }
3771
+
3627
3772
transformedDescription , err := expandComputeBackendServiceBackendDescription (original ["description" ], d , config )
3628
3773
if err != nil {
3629
3774
return nil , err
@@ -3707,6 +3852,10 @@ func expandComputeBackendServiceBackendCapacityScaler(v interface{}, d tpgresour
3707
3852
return v , nil
3708
3853
}
3709
3854
3855
+ func expandComputeBackendServiceBackendPreference (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
3856
+ return v , nil
3857
+ }
3858
+
3710
3859
func expandComputeBackendServiceBackendDescription (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
3711
3860
return v , nil
3712
3861
}
@@ -3987,6 +4136,13 @@ func expandComputeBackendServiceCdnPolicy(v interface{}, d tpgresource.Terraform
3987
4136
original := raw .(map [string ]interface {})
3988
4137
transformed := make (map [string ]interface {})
3989
4138
4139
+ transformedRequestCoalescing , err := expandComputeBackendServiceCdnPolicyRequestCoalescing (original ["request_coalescing" ], d , config )
4140
+ if err != nil {
4141
+ return nil , err
4142
+ } else {
4143
+ transformed ["requestCoalescing" ] = transformedRequestCoalescing
4144
+ }
4145
+
3990
4146
transformedCacheKeyPolicy , err := expandComputeBackendServiceCdnPolicyCacheKeyPolicy (original ["cache_key_policy" ], d , config )
3991
4147
if err != nil {
3992
4148
return nil , err
@@ -4060,6 +4216,10 @@ func expandComputeBackendServiceCdnPolicy(v interface{}, d tpgresource.Terraform
4060
4216
return transformed , nil
4061
4217
}
4062
4218
4219
+ func expandComputeBackendServiceCdnPolicyRequestCoalescing (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
4220
+ return v , nil
4221
+ }
4222
+
4063
4223
func expandComputeBackendServiceCdnPolicyCacheKeyPolicy (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
4064
4224
l := v .([]interface {})
4065
4225
if len (l ) == 0 || l [0 ] == nil {
@@ -4892,6 +5052,20 @@ func expandComputeBackendServiceLogConfig(v interface{}, d tpgresource.Terraform
4892
5052
transformed ["sampleRate" ] = transformedSampleRate
4893
5053
}
4894
5054
5055
+ transformedOptionalMode , err := expandComputeBackendServiceLogConfigOptionalMode (original ["optional_mode" ], d , config )
5056
+ if err != nil {
5057
+ return nil , err
5058
+ } else if val := reflect .ValueOf (transformedOptionalMode ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5059
+ transformed ["optionalMode" ] = transformedOptionalMode
5060
+ }
5061
+
5062
+ transformedOptionalFields , err := expandComputeBackendServiceLogConfigOptionalFields (original ["optional_fields" ], d , config )
5063
+ if err != nil {
5064
+ return nil , err
5065
+ } else if val := reflect .ValueOf (transformedOptionalFields ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5066
+ transformed ["optionalFields" ] = transformedOptionalFields
5067
+ }
5068
+
4895
5069
return transformed , nil
4896
5070
}
4897
5071
@@ -4903,10 +5077,52 @@ func expandComputeBackendServiceLogConfigSampleRate(v interface{}, d tpgresource
4903
5077
return v , nil
4904
5078
}
4905
5079
5080
+ func expandComputeBackendServiceLogConfigOptionalMode (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5081
+ return v , nil
5082
+ }
5083
+
5084
+ func expandComputeBackendServiceLogConfigOptionalFields (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5085
+ return v , nil
5086
+ }
5087
+
4906
5088
func expandComputeBackendServiceServiceLbPolicy (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
4907
5089
return v , nil
4908
5090
}
4909
5091
5092
+ func expandComputeBackendServiceMaxStreamDuration (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5093
+ l := v .([]interface {})
5094
+ if len (l ) == 0 || l [0 ] == nil {
5095
+ return nil , nil
5096
+ }
5097
+ raw := l [0 ]
5098
+ original := raw .(map [string ]interface {})
5099
+ transformed := make (map [string ]interface {})
5100
+
5101
+ transformedSeconds , err := expandComputeBackendServiceMaxStreamDurationSeconds (original ["seconds" ], d , config )
5102
+ if err != nil {
5103
+ return nil , err
5104
+ } else if val := reflect .ValueOf (transformedSeconds ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5105
+ transformed ["seconds" ] = transformedSeconds
5106
+ }
5107
+
5108
+ transformedNanos , err := expandComputeBackendServiceMaxStreamDurationNanos (original ["nanos" ], d , config )
5109
+ if err != nil {
5110
+ return nil , err
5111
+ } else if val := reflect .ValueOf (transformedNanos ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
5112
+ transformed ["nanos" ] = transformedNanos
5113
+ }
5114
+
5115
+ return transformed , nil
5116
+ }
5117
+
5118
+ func expandComputeBackendServiceMaxStreamDurationSeconds (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5119
+ return v , nil
5120
+ }
5121
+
5122
+ func expandComputeBackendServiceMaxStreamDurationNanos (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
5123
+ return v , nil
5124
+ }
5125
+
4910
5126
func resourceComputeBackendServiceEncoder (d * schema.ResourceData , meta interface {}, obj map [string ]interface {}) (map [string ]interface {}, error ) {
4911
5127
backendsRaw , ok := obj ["backends" ]
4912
5128
if ! ok {
0 commit comments