Interview Prep/Terraform/Modules and Code Structure

Stack B needs the VPC ID created by stack A. Do you use `terraform_remote_state`, SSM parameters or a data source?

IntermediateScenarioModules and Code Structure
Answer

Situation read → Cross-stack data sharing, with different coupling levels.

What I'd do →

  1. Prefer data sources (aws_vpc by tag) when the thing is discoverable.
  2. Use SSM parameters or Secrets Manager as an explicit published contract between teams.
  3. Use terraform_remote_state only inside one team where read access to the whole state is acceptable.

Why → terraform_remote_state exposes the entire state, including secrets, to the reader, and couples stacks to output names and the backend.

Interview tip → "Publish what you intend to share; don't share the whole state."

All Terraform questions Roadmap: Terraform

More on Modules and Code Structure