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 →
- Separate the stacks: stack A creates the RDS instance and outputs the endpoint.
- Stack B reads it with
terraform_remote_stateor an SSM parameter and configures the provider. - For a one-off bootstrap, use two-phase apply with
-targetand 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."
More on Workflow and Providers
A new teammate is about to run Terraform for the first time against a shared dev account. Which commands do you walk them through, and in what order?BeginnerYour manager asks why we bother with `terraform plan` when `apply` shows the same diff before asking for confirmation. What do you say?BeginnerTwo engineers get different provider versions and see different plans for the same code. How do you stop this?BeginnerSomeone committed the `.terraform/` directory to the repo. What should be in version control and what should not?BeginnerThe same configuration must create a VPC in `us-east-1` and a DR copy of a bucket in `eu-west-1`. How do you do it with one root module?IntermediateYou must deploy the same stack into 12 AWS accounts. How do you handle credentials and provider configuration?Intermediate