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 →
- Use the provider's
execplugin (as inaws eks get-token) so the token is fetched at run time and never stored. - 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.
More on Secrets Provisioners and Policy as Code
A developer hardcodes a DB password in `terraform.tfvars` and commits it. What do you do right now, and what's the long-term fix?BeginnerHow do you avoid Terraform persisting a secret in state when creating a secret in AWS Secrets Manager?AdvancedSomeone wants a `remote-exec` provisioner to configure servers after creation. What's your advice?BeginnerYou must run a one-off command after a resource is created, such as registering with an external system.IntermediateHow do you generate and manage the master password for a new RDS instance?IntermediateCompare Sentinel, OPA/Conftest and Checkov for policy as code.Intermediate