Skip to content

Commit 15dc2c7

Browse files
authored
Make GKE cluster enable_l4_ilb_subsetting a computed field (#15814)
1 parent 1515c1c commit 15dc2c7

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2353,8 +2353,8 @@ func ResourceContainerCluster() *schema.Resource {
23532353
"enable_l4_ilb_subsetting": {
23542354
Type: schema.TypeBool,
23552355
Optional: true,
2356+
Computed: true,
23562357
Description: `Whether L4ILB Subsetting is enabled for this cluster.`,
2357-
Default: false,
23582358
},
23592359
"disable_l4_lb_firewall_reconciliation": {
23602360
Type: schema.TypeBool,

mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,50 @@ func TestAccContainerCluster_withILBSubsetting(t *testing.T) {
621621
})
622622
}
623623

624+
func TestAccContainerCluster_omittedILBSubsetting(t *testing.T) {
625+
t.Parallel()
626+
627+
clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
628+
npName := fmt.Sprintf("tf-test-cluster-nodepool-%s", acctest.RandString(t, 10))
629+
networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
630+
subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
631+
632+
acctest.VcrTest(t, resource.TestCase{
633+
PreCheck: func() { acctest.AccTestPreCheck(t) },
634+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
635+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
636+
Steps: []resource.TestStep{
637+
{
638+
Config: testAccContainerCluster_omittedILBSubSetting(clusterName, npName, networkName, subnetworkName),
639+
},
640+
{
641+
ResourceName: "google_container_cluster.confidential_nodes",
642+
ImportState: true,
643+
ImportStateVerify: true,
644+
ImportStateVerifyIgnore: []string{"deletion_protection"},
645+
},
646+
{
647+
Config: testAccContainerCluster_withILBSubSetting(clusterName, npName, networkName, subnetworkName),
648+
},
649+
{
650+
ResourceName: "google_container_cluster.confidential_nodes",
651+
ImportState: true,
652+
ImportStateVerify: true,
653+
ImportStateVerifyIgnore: []string{"deletion_protection"},
654+
},
655+
{
656+
Config: testAccContainerCluster_omittedILBSubSetting(clusterName, npName, networkName, subnetworkName),
657+
},
658+
{
659+
ResourceName: "google_container_cluster.confidential_nodes",
660+
ImportState: true,
661+
ImportStateVerify: true,
662+
ImportStateVerifyIgnore: []string{"deletion_protection"},
663+
},
664+
},
665+
})
666+
}
667+
624668
func TestAccContainerCluster_disableL4LbFirewallReconciliation(t *testing.T) {
625669
t.Parallel()
626670

@@ -7837,6 +7881,33 @@ resource "google_container_cluster" "confidential_nodes" {
78377881
`, clusterName, npName, networkName, subnetworkName)
78387882
}
78397883

7884+
func testAccContainerCluster_omittedILBSubSetting(clusterName, npName, networkName, subnetworkName string) string {
7885+
return fmt.Sprintf(`
7886+
resource "google_container_cluster" "confidential_nodes" {
7887+
name = "%s"
7888+
location = "us-central1-a"
7889+
release_channel {
7890+
channel = "RAPID"
7891+
}
7892+
7893+
node_pool {
7894+
name = "%s"
7895+
initial_node_count = 1
7896+
node_config {
7897+
machine_type = "e2-medium"
7898+
}
7899+
}
7900+
7901+
// enable_l4_ilb_subsetting omitted
7902+
7903+
network = "%s"
7904+
subnetwork = "%s"
7905+
7906+
deletion_protection = false
7907+
}
7908+
`, clusterName, npName, networkName, subnetworkName)
7909+
}
7910+
78407911
func testAccContainerCluster_disableILBSubSetting(clusterName, npName, networkName, subnetworkName string) string {
78417912
return fmt.Sprintf(`
78427913
resource "google_container_cluster" "confidential_nodes" {

0 commit comments

Comments
 (0)