@@ -4066,6 +4066,82 @@ resource "google_container_cluster" "with_private_endpoint_subnetwork" {
4066
4066
` , containerNetName , s1Name , s1Cidr , s2Name , s2Cidr , clusterName )
4067
4067
}
4068
4068
4069
+ func TestAccContainerCluster_withPrivateClusterConfigPrivateEndpointSubnetwork (t * testing.T ) {
4070
+ t .Parallel ()
4071
+
4072
+ r := acctest .RandString (t , 10 )
4073
+
4074
+ clusterName := fmt .Sprintf ("tf-test-cluster-%s" , acctest .RandString (t , 10 ))
4075
+ containerNetName := fmt .Sprintf ("tf-test-container-net-%s" , r )
4076
+
4077
+ acctest .VcrTest (t , resource.TestCase {
4078
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
4079
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
4080
+ CheckDestroy : testAccCheckContainerClusterDestroyProducer (t ),
4081
+ Steps : []resource.TestStep {
4082
+ {
4083
+ Config : testAccContainerCluster_withPrivateClusterConfigPrivateEndpointSubnetwork (containerNetName , clusterName ),
4084
+ },
4085
+ {
4086
+ ResourceName : "google_container_cluster.with_private_endpoint_subnetwork" ,
4087
+ ImportState : true ,
4088
+ ImportStateVerify : true ,
4089
+ ImportStateVerifyIgnore : []string {"min_master_version" },
4090
+ },
4091
+ },
4092
+ })
4093
+ }
4094
+
4095
+ func testAccContainerCluster_withPrivateClusterConfigPrivateEndpointSubnetwork (containerNetName , clusterName string ) string {
4096
+ return fmt .Sprintf (`
4097
+ resource "google_compute_network" "container_network" {
4098
+ name = "%s"
4099
+ auto_create_subnetworks = false
4100
+ }
4101
+
4102
+ resource "google_compute_subnetwork" "container_subnetwork" {
4103
+ name = google_compute_network.container_network.name
4104
+ network = google_compute_network.container_network.name
4105
+ ip_cidr_range = "10.0.36.0/24"
4106
+ region = "us-central1"
4107
+ private_ip_google_access = true
4108
+
4109
+ secondary_ip_range {
4110
+ range_name = "pod"
4111
+ ip_cidr_range = "10.0.0.0/19"
4112
+ }
4113
+
4114
+ secondary_ip_range {
4115
+ range_name = "svc"
4116
+ ip_cidr_range = "10.0.32.0/22"
4117
+ }
4118
+ }
4119
+
4120
+ resource "google_container_cluster" "with_private_endpoint_subnetwork" {
4121
+ name = "%s"
4122
+ location = "us-central1-a"
4123
+ initial_node_count = 1
4124
+ networking_mode = "VPC_NATIVE"
4125
+
4126
+ network = google_compute_network.container_network.name
4127
+ subnetwork = google_compute_subnetwork.container_subnetwork.name
4128
+
4129
+ private_cluster_config {
4130
+ enable_private_nodes = true
4131
+ enable_private_endpoint = true
4132
+ private_endpoint_subnetwork = google_compute_subnetwork.container_subnetwork.name
4133
+ }
4134
+ master_authorized_networks_config {
4135
+ gcp_public_cidrs_access_enabled = false
4136
+ }
4137
+ ip_allocation_policy {
4138
+ cluster_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[0].range_name
4139
+ services_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[1].range_name
4140
+ }
4141
+ }
4142
+ ` , containerNetName , clusterName )
4143
+ }
4144
+
4069
4145
func TestAccContainerCluster_withEnablePrivateEndpointToggle (t * testing.T ) {
4070
4146
t .Parallel ()
4071
4147
0 commit comments