Working in a project that I already used in the pass. I tried to create the same infrastructure in AWS using the same code, but this time I have some issues creation the service account resource. I created my EKS cluster in AWS using terraform and I have other terraform to create the k8 resources.
When I tried to create the service account I’m getting
Error: Waiting for default secret of "template/template" to appear
I tried following several posts, without any luck to do this work.
My service account declaration looks like:
resource "kubernetes_service_account_v1" "template_service_account" {
metadata {
name = "template"
namespace = kubernetes_namespace.template_namespace.metadata.0.name
}
automount_service_account_token = true
}
My secret:
resource "kubernetes_secret_v1" "template_secret" {
metadata {
name = "template"
namespace = kubernetes_service_account_v1.template_service_account.metadata[0].namespace
annotations = {
"kubernetes.io/service-account.name" = kubernetes_service_account_v1.template_service_account.metadata[0].name
}
}
type = "kubernetes.io/service-account-token"
depends_on = [kubernetes_namespace.template_namespace, kubernetes_service_account_v1.template_service_account]
}
My namespace
resource "kubernetes_namespace" "template_namespace" {
metadata {
annotations = {
name = "template"
}
labels = {
type = "local"
}
name = "template"
}
}
I read a post from here /questions/78008897/how-should-a-kubernetes-service-account-and-token-be-configured-in-terraform-to but doesn’t work to me.
I tried using v1 and common version of resource of terraform, and I could figure out the solution.
Can someone help me.
I expected create my service account with the secret.
1