Skip to content

Commit

Permalink
acceptance test: Suppress private_endpoint_subnetwork when master_ipv…
Browse files Browse the repository at this point in the history
…4_cidr_block is set

Signed-off-by: Francis Liu <[email protected]>
  • Loading branch information
Francis-Liu committed Mar 25, 2024
1 parent 8ce0dbd commit 2b7dcb8
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5643,6 +5643,61 @@ resource "google_container_cluster" "with_private_endpoint_subnetwork" {
`, containerNetName, clusterName)
}

func TestAccContainerCluster_withCidrBlockWithoutPrivateEndpointSubnetwork(t *testing.T) {
t.Parallel()

clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
containerNetName := fmt.Sprintf("tf-test-container-net-%s", acctest.RandString(t, 10))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccContainerCluster_withCidrBlockWithoutPrivateEndpointSubnetwork(containerNetName, clusterName, "us-central1-a"),
},
{
ResourceName: "google_container_cluster.with_private_flexible_cluster",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"},
},
},
})
}

func testAccContainerCluster_withCidrBlockWithoutPrivateEndpointSubnetwork(containerNetName, clusterName, location string) string {
return fmt.Sprintf(`
resource "google_compute_network" "container_network" {
name = "%s"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "container_subnetwork" {
name = google_compute_network.container_network.name
network = google_compute_network.container_network.name
ip_cidr_range = "10.0.36.0/24"
}

resource "google_container_cluster" "with_private_flexible_cluster" {
name = "%s"
location = "%s"
min_master_version = "1.29"
initial_node_count = 1

networking_mode = "VPC_NATIVE"
network = google_compute_network.container_network.name
subnetwork = google_compute_subnetwork.container_subnetwork.name

private_cluster_config {
enable_private_nodes = true
master_ipv4_cidr_block = "10.42.0.0/28"
}
}
`, containerNetName, clusterName, location)
}

func TestAccContainerCluster_withEnablePrivateEndpointToggle(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 2b7dcb8

Please sign in to comment.