Interview Prep/Terraform/Workflow and Providers

A resource needs a provider whose configuration comes from another resource's output in the same apply (for example a DB provider pointed at a new RDS endpoint). How do you handle it?

AdvancedScenarioWorkflow and Providers
Answer

Situation read → Same chicken-and-egg as Kubernetes, but for a database or Vault provider.

What I'd do →

  1. Separate the stacks: stack A creates the RDS instance and outputs the endpoint.
  2. Stack B reads it with terraform_remote_state or an SSM parameter and configures the provider.
  3. For a one-off bootstrap, use two-phase apply with -target and document it as an exception.

Why → Provider configuration must be known when the provider initializes. Unknown values at that moment produce errors or silently wrong defaults.

Interview tip → "Providers configured from resource attributes are a code smell; split by lifecycle."

All Terraform questions Roadmap: Terraform

More on Workflow and Providers