Interview Prep/Terraform/Workflow and Providers

How should an engineer authenticate Terraform to AWS from a laptop? Someone suggests hardcoding keys in the provider block.

IntermediateScenarioWorkflow and Providers
Answer

Situation read → Hardcoded keys end up in Git and in state-adjacent files.

What I'd do →

  1. Reject the hardcoded keys.
  2. Use AWS IAM Identity Center: aws sso login --profile dev, then export AWS_PROFILE=dev.
  3. Leave the provider block credential-free and let the default credential chain resolve identity.
provider "aws" {
  region = "ap-south-1"
}

Why → Short-lived SSO credentials expire on their own and are tied to a person, which also helps CloudTrail attribution.

Interview tip → Say "the provider block should contain no secrets, ever."

All Terraform questions Roadmap: Terraform

More on Workflow and Providers