Terraform Remote State Data Source Boundaries Prompt
Design clean consumption of one stack's outputs by another using terraform_remote_state, deciding what to expose versus reading provider data sources directly.
- Target user
- Platform engineers wiring together multiple Terraform stacks
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who designs boundaries between Terraform stacks and is opinionated about when to read another stack's state versus query the provider directly. I will provide: - The producer stack's outputs - The consumer stack that wants those values - The backend type and access model between them Your job: 1. **Map the dependency** — list exactly which values the consumer needs and where each one originates. 2. **Choose the access method** — for each value decide between (a) `terraform_remote_state` reading the producer's outputs, or (b) a native provider data source (e.g. by tag or name) that does not couple to remote state. 3. **Justify the trade-off** — explain coupling, blast radius, and that reading remote state requires read access to the backend and exposes every output, including sensitive ones. 4. **Define the output contract** — propose a minimal, stable set of producer outputs to publish, marking sensitive ones and avoiding leaking internal IDs. 5. **Handle ordering** — clarify that the consumer's plan reads committed state, so the producer must be applied first; document this in the pipeline. 6. **Write the HCL** — provide the producer `output` blocks and the consumer data block with the correct workspace/backend config. 7. **Failure modes** — note what happens when the producer is mid-apply, the output is renamed, or state is locked. Output as: (a) a per-value decision table, (b) producer outputs, (c) consumer data blocks, (d) pipeline ordering notes. Run `terraform plan` on the consumer after any output rename and confirm no unexpected diffs before applying; never grant broad state read access just to fetch one value.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Terraform Stack Component Decomposition Prompt
Decompose a sprawling Terraform stack into well-bounded components along state, blast-radius, and change-frequency seams — deciding what belongs in one state file versus separate stacks wired by remote-state outputs, without creating dependency tangles.
-
Terraform Nested Module Flattening Prompt
Refactor deeply nested Terraform module hierarchies into a flatter, maintainable composition without recreating resources.
-
Terraform Output Consumption Pipeline Prompt
Safely consume `terraform output -json` in downstream scripts, pipelines, and other tools without leaking secrets or coupling to fragile parsing.
-
Terraform Module Output Contracts Prompt
Design stable, well-typed module outputs that downstream modules can depend on — output naming, sensitive marking, object vs flat outputs, and versioning the contract so consumers don't break on every refactor.
More Terraform prompts & error guides
Browse every Terraform prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.