Skip to content

[Terraform] Fix ServiceAccount naming in Kubernetes auth roles #13

Description

@colek42

Problem

The vault-config Terraform module's Kubernetes auth roles are bound to hardcoded ServiceAccount names without the Helm release prefix, but Helm charts may use prefixed names.

Current State

# Lines 192, 202, 212 in modules/vault-config/main.tf
resource "vault_kubernetes_auth_backend_role" "judge_api" {
  backend                          = vault_auth_backend.kubernetes.path
  role_name                        = "judge-api"
  bound_service_account_names      = ["judge-api"]  # Hardcoded without prefix
  bound_service_account_namespaces = [var.judge_namespace]
  token_policies                   = [vault_policy.judge_api.name]
  token_ttl                        = 86400
}

Problem

  • Helm charts may create ServiceAccounts with release prefix: judge-platform-judge-api
  • Current Terraform binds to judge-api only
  • ESO cannot authenticate if names don't match

Desired State

Make ServiceAccount names configurable:

variable "judge_api_service_account" {
  default = "judge-api"
  description = "ServiceAccount name for judge-api (may include release prefix)"
}

resource "vault_kubernetes_auth_backend_role" "judge_api" {
  ...
  bound_service_account_names = [var.judge_api_service_account]
  ...
}

OR require consistent naming in Helm charts.

Files to Update

  • modules/vault-config/main.tf
  • modules/vault-config/variables.tf

Related Issues

Impact

  • High Priority: ESO authentication fails if names don't match
  • Blocks multi-release deployments

Labels

  • bug
  • terraform
  • vault
  • critical

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions