@@ -3522,13 +3522,14 @@ func TestAccContainerCluster_withSecretManagerConfig(t *testing.T) {
3522
3522
clusterName := fmt .Sprintf ("tf-test-cluster-%s" , acctest .RandString (t , 10 ))
3523
3523
networkName := acctest .BootstrapSharedTestNetwork (t , "gke-cluster" )
3524
3524
subnetworkName := acctest .BootstrapSubnet (t , "gke-cluster" , networkName )
3525
+ pid := envvar .GetTestProjectFromEnv ()
3525
3526
acctest .VcrTest (t , resource.TestCase {
3526
3527
PreCheck : func () { acctest .AccTestPreCheck (t ) },
3527
3528
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
3528
3529
CheckDestroy : testAccCheckContainerClusterDestroyProducer (t ),
3529
3530
Steps : []resource.TestStep {
3530
3531
{
3531
- Config : testAccContainerCluster_basic ( clusterName , networkName , subnetworkName ),
3532
+ Config : testAccContainerCluster_forSecretManagerConfig ( pid , clusterName , networkName , subnetworkName ),
3532
3533
},
3533
3534
{
3534
3535
ResourceName : "google_container_cluster.primary" ,
@@ -3537,7 +3538,7 @@ func TestAccContainerCluster_withSecretManagerConfig(t *testing.T) {
3537
3538
ImportStateVerifyIgnore : []string {"deletion_protection" },
3538
3539
},
3539
3540
{
3540
- Config : testAccContainerCluster_withSecretManagerConfigEnabled (clusterName , networkName , subnetworkName ),
3541
+ Config : testAccContainerCluster_withSecretManagerConfigEnabled (pid , clusterName , networkName , subnetworkName ),
3541
3542
},
3542
3543
{
3543
3544
ResourceName : "google_container_cluster.primary" ,
@@ -3546,16 +3547,7 @@ func TestAccContainerCluster_withSecretManagerConfig(t *testing.T) {
3546
3547
ImportStateVerifyIgnore : []string {"deletion_protection" },
3547
3548
},
3548
3549
{
3549
- Config : testAccContainerCluster_withSecretManagerConfigUpdated (clusterName , networkName , subnetworkName ),
3550
- },
3551
- {
3552
- ResourceName : "google_container_cluster.primary" ,
3553
- ImportState : true ,
3554
- ImportStateVerify : true ,
3555
- ImportStateVerifyIgnore : []string {"deletion_protection" },
3556
- },
3557
- {
3558
- Config : testAccContainerCluster_basic (clusterName , networkName , subnetworkName ),
3550
+ Config : testAccContainerCluster_withSecretManagerConfigUpdated (pid , clusterName , networkName , subnetworkName ),
3559
3551
},
3560
3552
{
3561
3553
ResourceName : "google_container_cluster.primary" ,
@@ -5440,6 +5432,26 @@ resource "google_container_cluster" "primary" {
5440
5432
` , name , networkName , subnetworkName )
5441
5433
}
5442
5434
5435
+ func testAccContainerCluster_forSecretManagerConfig (projectID , name , networkName , subnetworkName string ) string {
5436
+ return fmt .Sprintf (`
5437
+ data "google_project" "project" {
5438
+ project_id = "%s"
5439
+ }
5440
+ resource "google_container_cluster" "primary" {
5441
+ name = "%s"
5442
+ location = "us-central1-a"
5443
+ initial_node_count = 1
5444
+ network = "%s"
5445
+ subnetwork = "%s"
5446
+
5447
+ deletion_protection = false
5448
+ workload_identity_config {
5449
+ workload_pool = "${data.google_project.project.project_id}.svc.id.goog"
5450
+ }
5451
+ }
5452
+ ` , projectID , name , networkName , subnetworkName )
5453
+ }
5454
+
5443
5455
func testAccContainerCluster_networkingModeRoutes (firstName , secondName string ) string {
5444
5456
return fmt .Sprintf (`
5445
5457
resource "google_container_cluster" "primary" {
@@ -9591,8 +9603,11 @@ resource "google_container_cluster" "primary" {
9591
9603
` , name , networkName , subnetworkName )
9592
9604
}
9593
9605
9594
- func testAccContainerCluster_withSecretManagerConfigEnabled (name , networkName , subnetworkName string ) string {
9606
+ func testAccContainerCluster_withSecretManagerConfigEnabled (projectID , name , networkName , subnetworkName string ) string {
9595
9607
return fmt .Sprintf (`
9608
+ data "google_project" "project" {
9609
+ project_id = "%s"
9610
+ }
9596
9611
resource "google_container_cluster" "primary" {
9597
9612
name = "%s"
9598
9613
location = "us-central1-a"
@@ -9603,12 +9618,18 @@ resource "google_container_cluster" "primary" {
9603
9618
deletion_protection = false
9604
9619
network = "%s"
9605
9620
subnetwork = "%s"
9621
+ workload_identity_config {
9622
+ workload_pool = "${data.google_project.project.project_id}.svc.id.goog"
9623
+ }
9606
9624
}
9607
- ` , name , networkName , subnetworkName )
9625
+ ` , projectID , name , networkName , subnetworkName )
9608
9626
}
9609
9627
9610
- func testAccContainerCluster_withSecretManagerConfigUpdated (name , networkName , subnetworkName string ) string {
9628
+ func testAccContainerCluster_withSecretManagerConfigUpdated (projectID , name , networkName , subnetworkName string ) string {
9611
9629
return fmt .Sprintf (`
9630
+ data "google_project" "project" {
9631
+ project_id = "%s"
9632
+ }
9612
9633
resource "google_container_cluster" "primary" {
9613
9634
name = "%s"
9614
9635
location = "us-central1-a"
@@ -9620,8 +9641,11 @@ resource "google_container_cluster" "primary" {
9620
9641
deletion_protection = false
9621
9642
network = "%s"
9622
9643
subnetwork = "%s"
9644
+ workload_identity_config {
9645
+ workload_pool = "${data.google_project.project.project_id}.svc.id.goog"
9646
+ }
9623
9647
}
9624
- ` , name , networkName , subnetworkName )
9648
+ ` , projectID , name , networkName , subnetworkName )
9625
9649
}
9626
9650
9627
9651
func testAccContainerCluster_withLoggingConfigEnabled (name , networkName , subnetworkName string ) string {
0 commit comments