What is the terraform_remote_state data source?

Answer

The terraform_remote_state data source reads the outputs of another Terraform state file, enabling cross-stack references without hardcoding values. Example: read VPC ID from a network stack into an application stack: data "terraform_remote_state" "network" { backend = "s3"; config = { bucket = "my-tf-state"; key = "network/terraform.tfstate"; region = "us-east-1" } }. Reference: module "app" { vpc_id = data.terraform_remote_state.network.outputs.vpc_id }. Requirements: the referenced state must be accessible (correct IAM permissions) and the output must be declared in the source configuration. Limitation: this creates a tight coupling between stacks — the referencing stack fails if the referenced state doesn't exist or its outputs change. Alternative: use SSM Parameter Store, Consul, or other external stores for loose coupling between independent stacks.