@@ -4730,6 +4730,82 @@ resource "google_container_cluster" "with_private_endpoint_subnetwork" {
47304730` , containerNetName , s1Name , s1Cidr , s2Name , s2Cidr , clusterName )
47314731}
47324732
4733+ func TestAccContainerCluster_withPrivateClusterConfigPrivateEndpointSubnetwork (t * testing.T ) {
4734+ t .Parallel ()
4735+
4736+ r := acctest .RandString (t , 10 )
4737+
4738+ clusterName := fmt .Sprintf ("tf-test-cluster-%s" , acctest .RandString (t , 10 ))
4739+ containerNetName := fmt .Sprintf ("tf-test-container-net-%s" , r )
4740+
4741+ acctest .VcrTest (t , resource.TestCase {
4742+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
4743+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
4744+ CheckDestroy : testAccCheckContainerClusterDestroyProducer (t ),
4745+ Steps : []resource.TestStep {
4746+ {
4747+ Config : testAccContainerCluster_withPrivateClusterConfigPrivateEndpointSubnetwork (containerNetName , clusterName ),
4748+ },
4749+ {
4750+ ResourceName : "google_container_cluster.with_private_endpoint_subnetwork" ,
4751+ ImportState : true ,
4752+ ImportStateVerify : true ,
4753+ ImportStateVerifyIgnore : []string {"min_master_version" },
4754+ },
4755+ },
4756+ })
4757+ }
4758+
4759+ func testAccContainerCluster_withPrivateClusterConfigPrivateEndpointSubnetwork (containerNetName , clusterName string ) string {
4760+ return fmt .Sprintf (`
4761+ resource "google_compute_network" "container_network" {
4762+ name = "%s"
4763+ auto_create_subnetworks = false
4764+ }
4765+
4766+ resource "google_compute_subnetwork" "container_subnetwork" {
4767+ name = google_compute_network.container_network.name
4768+ network = google_compute_network.container_network.name
4769+ ip_cidr_range = "10.0.36.0/24"
4770+ region = "us-central1"
4771+ private_ip_google_access = true
4772+
4773+ secondary_ip_range {
4774+ range_name = "pod"
4775+ ip_cidr_range = "10.0.0.0/19"
4776+ }
4777+
4778+ secondary_ip_range {
4779+ range_name = "svc"
4780+ ip_cidr_range = "10.0.32.0/22"
4781+ }
4782+ }
4783+
4784+ resource "google_container_cluster" "with_private_endpoint_subnetwork" {
4785+ name = "%s"
4786+ location = "us-central1-a"
4787+ initial_node_count = 1
4788+ networking_mode = "VPC_NATIVE"
4789+
4790+ network = google_compute_network.container_network.name
4791+ subnetwork = google_compute_subnetwork.container_subnetwork.name
4792+
4793+ private_cluster_config {
4794+ enable_private_nodes = true
4795+ enable_private_endpoint = true
4796+ private_endpoint_subnetwork = google_compute_subnetwork.container_subnetwork.name
4797+ }
4798+ master_authorized_networks_config {
4799+ gcp_public_cidrs_access_enabled = false
4800+ }
4801+ ip_allocation_policy {
4802+ cluster_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[0].range_name
4803+ services_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[1].range_name
4804+ }
4805+ }
4806+ ` , containerNetName , clusterName )
4807+ }
4808+
47334809func TestAccContainerCluster_withEnablePrivateEndpointToggle (t * testing.T ) {
47344810 t .Parallel ()
47354811
0 commit comments