Skill 6.3.3

Reading remote state outputs

Key Concepts

data "terraform_remote_state" "network" { backend = "s3" config = { bucket = "acme-tfstate" key = "network/terraform.tfstate" region = "eu-west-1" } } lets an application configuration read data.terraform_remote_state.network.outputs.subnet_ids. Only root module outputs are available.

The reader needs access to the whole state, which can contain sensitive values, so HashiCorp recommends publishing shared values through a dedicated store, such as a parameter store, or using HCP Terraform's tfe_outputs data source, which exposes only outputs. Loose coupling through outputs lets separate teams own separate configurations.