Skip to content

Commit 5fbd723

Browse files
support master_global_access_config for flexible cluster (#8314) (#5995)
Signed-off-by: Modular Magician <[email protected]>
1 parent 3783c85 commit 5fbd723

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

.changelog/8314.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
container: support master_global_access_config for flexible cluster
3+
```

google-beta/resource_container_cluster_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,36 @@ func TestAccContainerCluster_withPrivateClusterConfigMissingCidrBlock_withAutopi
996996
})
997997
}
998998

999+
func TestAccContainerCluster_withPrivateClusterConfigGlobalAccessEnabledOnly(t *testing.T) {
1000+
t.Parallel()
1001+
1002+
clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
1003+
1004+
acctest.VcrTest(t, resource.TestCase{
1005+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1006+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1007+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
1008+
Steps: []resource.TestStep{
1009+
{
1010+
Config: testAccContainerCluster_withPrivateClusterConfigGlobalAccessEnabledOnly(clusterName, true),
1011+
},
1012+
{
1013+
ResourceName: "google_container_cluster.with_private_cluster",
1014+
ImportState: true,
1015+
ImportStateVerify: true,
1016+
},
1017+
{
1018+
Config: testAccContainerCluster_withPrivateClusterConfigGlobalAccessEnabledOnly(clusterName, false),
1019+
},
1020+
{
1021+
ResourceName: "google_container_cluster.with_private_cluster",
1022+
ImportState: true,
1023+
ImportStateVerify: true,
1024+
},
1025+
},
1026+
})
1027+
}
1028+
9991029
func TestAccContainerCluster_withIntraNodeVisibility(t *testing.T) {
10001030
t.Parallel()
10011031

@@ -6754,6 +6784,22 @@ resource "google_container_cluster" "with_private_cluster" {
67546784
`, containerNetName, clusterName, masterGlobalAccessEnabled)
67556785
}
67566786

6787+
func testAccContainerCluster_withPrivateClusterConfigGlobalAccessEnabledOnly(clusterName string, masterGlobalAccessEnabled bool) string {
6788+
return fmt.Sprintf(`
6789+
resource "google_container_cluster" "with_private_cluster" {
6790+
name = "%s"
6791+
location = "us-central1-a"
6792+
initial_node_count = 1
6793+
private_cluster_config {
6794+
enable_private_endpoint = false
6795+
master_global_access_config {
6796+
enabled = %t
6797+
}
6798+
}
6799+
}
6800+
`, clusterName, masterGlobalAccessEnabled)
6801+
}
6802+
67576803
func testAccContainerCluster_withShieldedNodes(clusterName string, enabled bool) string {
67586804
return fmt.Sprintf(`
67596805
resource "google_container_cluster" "with_shielded_nodes" {

google-beta/services/container/resource_container_cluster.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5918,12 +5918,15 @@ func containerClusterPrivateClusterConfigSuppress(k, old, new string, d *schema.
59185918
// Do not suppress diffs when private_endpoint_subnetwork is configured
59195919
_, hasSubnet := d.GetOk("private_cluster_config.0.private_endpoint_subnetwork")
59205920

5921+
// Do not suppress diffs when master_global_access_config is configured
5922+
_, hasGlobalAccessConfig := d.GetOk("private_cluster_config.0.master_global_access_config")
5923+
59215924
if k == "private_cluster_config.0.enable_private_endpoint" {
59225925
return suppressEndpoint && !hasSubnet
59235926
} else if k == "private_cluster_config.0.enable_private_nodes" {
59245927
return suppressNodes && !hasSubnet
59255928
} else if k == "private_cluster_config.#" {
5926-
return suppressEndpoint && suppressNodes && !hasSubnet
5929+
return suppressEndpoint && suppressNodes && !hasSubnet && !hasGlobalAccessConfig
59275930
}
59285931
return false
59295932
}

0 commit comments

Comments
 (0)