@@ -96,6 +96,20 @@ func rfc5545RecurrenceDiffSuppress(k, o, n string, d *schema.ResourceData) bool
96
96
return false
97
97
}
98
98
99
+ // Has enable_l4_ilb_subsetting been enabled before?
100
+ func isBeenEnabled (_ context.Context , old , new , _ interface {}) bool {
101
+ if old == nil || new == nil {
102
+ return false
103
+ }
104
+
105
+ // if subsetting is enabled, but is not now
106
+ if old .(bool ) && ! new .(bool ) {
107
+ return true
108
+ }
109
+
110
+ return false
111
+ }
112
+
99
113
func resourceContainerCluster () * schema.Resource {
100
114
return & schema.Resource {
101
115
UseJSONNumber : true ,
@@ -106,6 +120,7 @@ func resourceContainerCluster() *schema.Resource {
106
120
107
121
CustomizeDiff : customdiff .All (
108
122
resourceNodeConfigEmptyGuestAccelerator ,
123
+ customdiff .ForceNewIfChange ("enable_l4_ilb_subsetting" , isBeenEnabled ),
109
124
containerClusterAutopilotCustomizeDiff ,
110
125
containerClusterNodeVersionRemoveDefaultCustomizeDiff ,
111
126
containerClusterNetworkPolicyEmptyCustomizeDiff ,
@@ -1384,6 +1399,12 @@ func resourceContainerCluster() *schema.Resource {
1384
1399
Description : `Whether Intra-node visibility is enabled for this cluster. This makes same node pod to pod traffic visible for VPC network.` ,
1385
1400
ConflictsWith : []string {"enable_autopilot" },
1386
1401
},
1402
+ "enable_l4_ilb_subsetting" : {
1403
+ Type : schema .TypeBool ,
1404
+ Optional : true ,
1405
+ Description : `Whether L4ILB Subsetting is enabled for this cluster.` ,
1406
+ Default : false ,
1407
+ },
1387
1408
"private_ipv6_google_access" : {
1388
1409
Type : schema .TypeString ,
1389
1410
Optional : true ,
@@ -1591,6 +1612,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
1591
1612
DefaultSnatStatus : expandDefaultSnatStatus (d .Get ("default_snat_status" )),
1592
1613
DatapathProvider : d .Get ("datapath_provider" ).(string ),
1593
1614
PrivateIpv6GoogleAccess : d .Get ("private_ipv6_google_access" ).(string ),
1615
+ EnableL4ilbSubsetting : d .Get ("enable_l4_ilb_subsetting" ).(bool ),
1594
1616
DnsConfig : expandDnsConfig (d .Get ("dns_config" )),
1595
1617
},
1596
1618
MasterAuth : expandMasterAuth (d .Get ("master_auth" )),
@@ -1960,6 +1982,9 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
1960
1982
if err := d .Set ("notification_config" , flattenNotificationConfig (cluster .NotificationConfig )); err != nil {
1961
1983
return err
1962
1984
}
1985
+ if err := d .Set ("enable_l4_ilb_subsetting" , cluster .NetworkConfig .EnableL4ilbSubsetting ); err != nil {
1986
+ return fmt .Errorf ("Error setting enable_l4_ilb_subsetting: %s" , err )
1987
+ }
1963
1988
if err := d .Set ("cost_management_config" , flattenManagementConfig (cluster .CostManagementConfig )); err != nil {
1964
1989
return fmt .Errorf ("Error setting cost_management_config: %s" , err )
1965
1990
}
@@ -2315,6 +2340,43 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
2315
2340
log .Printf ("[INFO] GKE cluster %s Private IPv6 Google Access has been updated" , d .Id ())
2316
2341
}
2317
2342
2343
+ if d .HasChange ("enable_l4_ilb_subsetting" ) {
2344
+ // This field can be changed from false to true but not from false to true. CustomizeDiff handles that check.
2345
+ enabled := d .Get ("enable_l4_ilb_subsetting" ).(bool )
2346
+ req := & container.UpdateClusterRequest {
2347
+ Update : & container.ClusterUpdate {
2348
+ DesiredL4ilbSubsettingConfig : & container.ILBSubsettingConfig {
2349
+ Enabled : enabled ,
2350
+ ForceSendFields : []string {"Enabled" },
2351
+ },
2352
+ },
2353
+ }
2354
+ updateF := func () error {
2355
+ log .Println ("[DEBUG] updating enable_l4_ilb_subsetting" )
2356
+ name := containerClusterFullName (project , location , clusterName )
2357
+ clusterUpdateCall := config .NewContainerClient (userAgent ).Projects .Locations .Clusters .Update (name , req )
2358
+ if config .UserProjectOverride {
2359
+ clusterUpdateCall .Header ().Add ("X-Goog-User-Project" , project )
2360
+ }
2361
+ op , err := clusterUpdateCall .Do ()
2362
+ if err != nil {
2363
+ return err
2364
+ }
2365
+
2366
+ // Wait until it's updated
2367
+ err = containerOperationWait (config , op , project , location , "updating L4" , userAgent , d .Timeout (schema .TimeoutUpdate ))
2368
+ log .Println ("[DEBUG] done updating enable_intranode_visibility" )
2369
+ return err
2370
+ }
2371
+
2372
+ // Call update serially.
2373
+ if err := lockedCall (lockKey , updateF ); err != nil {
2374
+ return err
2375
+ }
2376
+
2377
+ log .Printf ("[INFO] GKE cluster %s L4 ILB Subsetting has been updated to %v" , d .Id (), enabled )
2378
+ }
2379
+
2318
2380
if d .HasChange ("cost_management_config" ) {
2319
2381
c := d .Get ("cost_management_config" )
2320
2382
req := & container.UpdateClusterRequest {
0 commit comments