@@ -5829,6 +5829,169 @@ func TestAccContainerCluster_autopilot_minimal(t *testing.T) {
5829
5829
})
5830
5830
}
5831
5831
5832
+ func TestAccContainerCluster_autopilot_withDNSConfig(t *testing.T) {
5833
+ t.Parallel()
5834
+
5835
+ clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
5836
+ acctest.VcrTest(t, resource.TestCase{
5837
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
5838
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
5839
+ CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
5840
+ Steps: []resource.TestStep{
5841
+ {
5842
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, false, false, ""),
5843
+ },
5844
+ {
5845
+ ResourceName: "google_container_cluster.primary",
5846
+ ImportState: true,
5847
+ ImportStateVerify: true,
5848
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5849
+ },
5850
+ {
5851
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, true, false, ""),
5852
+ },
5853
+ {
5854
+ ResourceName: "google_container_cluster.primary",
5855
+ ImportState: true,
5856
+ ImportStateVerify: true,
5857
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5858
+ },
5859
+ {
5860
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, false, true, ""),
5861
+ },
5862
+ {
5863
+ ResourceName: "google_container_cluster.primary",
5864
+ ImportState: true,
5865
+ ImportStateVerify: true,
5866
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5867
+ },
5868
+ {
5869
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, true, true, ""),
5870
+ },
5871
+ {
5872
+ ResourceName: "google_container_cluster.primary",
5873
+ ImportState: true,
5874
+ ImportStateVerify: true,
5875
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5876
+ },
5877
+ },
5878
+ })
5879
+ }
5880
+
5881
+ func TestAccContainerCluster_autopilot_withAdditiveVPC(t *testing.T) {
5882
+ t.Parallel()
5883
+
5884
+ domain := "additive.autopilot.example"
5885
+ clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
5886
+ acctest.VcrTest(t, resource.TestCase{
5887
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
5888
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
5889
+ CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
5890
+ Steps: []resource.TestStep{
5891
+ {
5892
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, false, false, domain),
5893
+ Check: resource.ComposeTestCheckFunc(
5894
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "dns_config.0.additive_vpc_scope_dns_domain", domain),
5895
+ ),
5896
+ },
5897
+ {
5898
+ ResourceName: "google_container_cluster.primary",
5899
+ ImportState: true,
5900
+ ImportStateVerify: true,
5901
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5902
+ },
5903
+ {
5904
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, true, false, domain),
5905
+ Check: resource.ComposeTestCheckFunc(
5906
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "dns_config.0.additive_vpc_scope_dns_domain", domain),
5907
+ ),
5908
+ },
5909
+ {
5910
+ ResourceName: "google_container_cluster.primary",
5911
+ ImportState: true,
5912
+ ImportStateVerify: true,
5913
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5914
+ },
5915
+ {
5916
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, false, true, domain),
5917
+ Check: resource.ComposeTestCheckFunc(
5918
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "dns_config.0.additive_vpc_scope_dns_domain", domain),
5919
+ ),
5920
+ },
5921
+ {
5922
+ ResourceName: "google_container_cluster.primary",
5923
+ ImportState: true,
5924
+ ImportStateVerify: true,
5925
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5926
+ },
5927
+ {
5928
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, true, true, domain),
5929
+ Check: resource.ComposeTestCheckFunc(
5930
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "dns_config.0.additive_vpc_scope_dns_domain", domain),
5931
+ ),
5932
+ },
5933
+ {
5934
+ ResourceName: "google_container_cluster.primary",
5935
+ ImportState: true,
5936
+ ImportStateVerify: true,
5937
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5938
+ },
5939
+ },
5940
+ })
5941
+ }
5942
+
5943
+ func TestAccContainerCluster_autopilot_withAdditiveVPCMutation(t *testing.T) {
5944
+ t.Parallel()
5945
+
5946
+ domain := "additive-mutating.autopilot.example"
5947
+ clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
5948
+ acctest.VcrTest(t, resource.TestCase{
5949
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
5950
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
5951
+ CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
5952
+ Steps: []resource.TestStep{
5953
+ {
5954
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, false, false, ""),
5955
+ Check: resource.ComposeTestCheckFunc(
5956
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "dns_config.0.additive_vpc_scope_dns_domain", ""),
5957
+ ),
5958
+ },
5959
+ {
5960
+ ResourceName: "google_container_cluster.primary",
5961
+ ImportState: true,
5962
+ ImportStateVerify: true,
5963
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5964
+ },
5965
+ {
5966
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, false, false, domain),
5967
+ Check: resource.ComposeTestCheckFunc(
5968
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "dns_config.0.additive_vpc_scope_dns_domain", domain),
5969
+ ),
5970
+ ConfigPlanChecks: resource.ConfigPlanChecks{PreApply: []plancheck.PlanCheck{plancheck.ExpectResourceAction("google_container_cluster.primary", plancheck.ResourceActionReplace)}},
5971
+ },
5972
+ {
5973
+ ResourceName: "google_container_cluster.primary",
5974
+ ImportState: true,
5975
+ ImportStateVerify: true,
5976
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5977
+ },
5978
+ {
5979
+ Config: testAccContainerCluster_autopilot_withDNSConfig(clusterName, true, false, false, ""),
5980
+ Check: resource.ComposeTestCheckFunc(
5981
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "dns_config.0.additive_vpc_scope_dns_domain", ""),
5982
+ ),
5983
+ ConfigPlanChecks: resource.ConfigPlanChecks{PreApply: []plancheck.PlanCheck{plancheck.ExpectResourceAction("google_container_cluster.primary", plancheck.ResourceActionReplace)}},
5984
+ },
5985
+ {
5986
+ ResourceName: "google_container_cluster.primary",
5987
+ ImportState: true,
5988
+ ImportStateVerify: true,
5989
+ ImportStateVerifyIgnore: []string{"deletion_protection"},
5990
+ },
5991
+ },
5992
+ })
5993
+ }
5994
+
5832
5995
func TestAccContainerCluster_autopilot_net_admin(t *testing.T) {
5833
5996
t.Parallel()
5834
5997
@@ -11066,6 +11229,42 @@ resource "google_container_cluster" "primary" {
11066
11229
}`, name)
11067
11230
}
11068
11231
11232
+ func testAccContainerCluster_autopilot_withDNSConfig(name string, dnsConfigSectionPresent, clusterDnsPresent, clusterDnsScopePresent bool, additiveVpcDnsDomain string) string {
11233
+ config := fmt.Sprintf(`
11234
+ resource "google_container_cluster" "primary" {
11235
+ name = "%s"
11236
+ location = "us-central1"
11237
+ enable_autopilot = true
11238
+ deletion_protection = false
11239
+ `, name)
11240
+ if dnsConfigSectionPresent {
11241
+ config += `
11242
+ dns_config {
11243
+ `
11244
+ if clusterDnsPresent {
11245
+ config += `
11246
+ cluster_dns = "CLOUD_DNS"
11247
+ `
11248
+ }
11249
+ if clusterDnsScopePresent {
11250
+ config += `
11251
+ cluster_dns_scope = "CLUSTER_SCOPE"
11252
+ `
11253
+ }
11254
+ if additiveVpcDnsDomain != "" {
11255
+ config += fmt.Sprintf(`
11256
+ additive_vpc_scope_dns_domain = "%s"
11257
+ `, additiveVpcDnsDomain)
11258
+ }
11259
+ config += `
11260
+ }
11261
+ `
11262
+ }
11263
+ config += `
11264
+ }`
11265
+ return config
11266
+ }
11267
+
11069
11268
func testAccContainerCluster_autopilot_net_admin(name, networkName, subnetworkName string, enabled bool) string {
11070
11269
return fmt.Sprintf(`
11071
11270
resource "google_container_cluster" "primary" {
0 commit comments