diff --git a/kubernetes/resource_kubernetes_pod_test.go b/kubernetes/resource_kubernetes_pod_test.go index e515cc92d5..fa672ff47e 100644 --- a/kubernetes/resource_kubernetes_pod_test.go +++ b/kubernetes/resource_kubernetes_pod_test.go @@ -595,6 +595,7 @@ func TestAccKubernetesPod_config_with_automount_service_account_token(t *testing podName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) imageName := "nginx:1.7.9" + saName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -602,7 +603,7 @@ func TestAccKubernetesPod_config_with_automount_service_account_token(t *testing CheckDestroy: testAccCheckKubernetesPodDestroy, Steps: []resource.TestStep{ { - Config: testAccKubernetesPodConfigWithAutomountServiceAccountToken(podName, imageName), + Config: testAccKubernetesPodConfigWithAutomountServiceAccountToken(saName, podName, imageName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckKubernetesPodExists("kubernetes_pod.test", &confPod), testAccCheckKubernetesServiceAccountExists("kubernetes_service_account.test", &confSA), @@ -1324,11 +1325,11 @@ resource "kubernetes_pod" "test" { `, podName, imageName, val) } -func testAccKubernetesPodConfigWithAutomountServiceAccountToken(podName, imageName string) string { +func testAccKubernetesPodConfigWithAutomountServiceAccountToken(saName string, podName string, imageName string) string { return fmt.Sprintf(` resource "kubernetes_service_account" "test" { metadata { - name = "foo" + name = "%s" } } @@ -1342,7 +1343,7 @@ resource "kubernetes_pod" "test" { } spec { - service_account_name = "foo" + service_account_name = "kubernetes_service_account.test.metadata.0.name" automount_service_account_token = true container { @@ -1350,8 +1351,6 @@ resource "kubernetes_pod" "test" { name = "containername" } } - - depends_on = [ "kubernetes_service_account.test" ] } -`, podName, imageName) +`, saName, podName, imageName) }