Terraform needs credentials for AWS, Datadog and Cloudflare in CI. How do you supply them securely?
IntermediateScenarioSecrets and Identity Management
Answer
Situation read → Multiple providers often means multiple static tokens. Minimise and federate.
What I'd do →
- AWS: OIDC role assumption, separate plan (read) and apply (write) roles.
- Others: store API tokens in Vault or Secrets Manager, fetch at job start using the AWS role or Vault JWT auth.
- Pass via env vars (
DD_API_KEY,CLOUDFLARE_API_TOKEN), never in.tfvarscommitted to git. - Mark sensitive variables with
sensitive = trueand useephemeralresources/variables (Terraform 1.10+) so values stay out of state where supported. - Scope each token to the zones or orgs it manages.
Why → One federated identity unlocks the rest, so there is only one trust root to protect.
Interview tip → Split plan and apply roles; PRs only ever get the read role.
More on Secrets and Identity Management
A team stores database passwords in a `.env` file committed to a private repo. How do you migrate them out?BeginnerYour CI pipeline uses long-lived AWS access keys stored as repository secrets. How do you replace them?IntermediateAn auditor asks how often you rotate database credentials. You currently never do. What do you build?IntermediatePods need AWS access. A developer mounted an IAM user's keys as a Kubernetes Secret. What do you propose instead?BeginnerShould you use Kubernetes Secrets, Sealed Secrets, External Secrets Operator or the Secrets Store CSI driver?IntermediateA Slack webhook URL and a Stripe live key were posted in a public GitHub issue. What is your response sequence?Beginner