Interview Prep/Terraform/Secrets Provisioners and Policy as Code

You must pass a Kubernetes auth token to a provider without writing it to state.

AdvancedScenarioSecrets Provisioners and Policy as Code
Answer

Situation read → Short-lived credentials shouldn't persist.

What I'd do →

  1. Use the provider's exec plugin (as in aws eks get-token) so the token is fetched at run time and never stored.
  2. On Terraform 1.10+, use ephemeral resources/values where the provider supports them.

Why → Values obtained by exec or marked ephemeral aren't saved in plan or state files.

Interview tip → Avoid data "aws_eks_cluster_auth" tokens for long runs; they expire after about 15 minutes.

All Terraform questions

More on Secrets Provisioners and Policy as Code