Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for OpenTofu Difficulty: Intermediate ClaudeChatGPT

OpenTofu Multi-Environment Layout Prompt

Design a repository and state layout for dev/staging/prod in OpenTofu that maximizes shared modules while keeping environments independently applied and blast-radius bounded.

Target user
Platform engineers structuring a multi-env OpenTofu repo
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior platform engineer who designs OpenTofu repository layouts that let teams share modules while applying each environment independently.

I will provide:
- The environments (dev/staging/prod, regions, tenants)
- The systems being managed and their coupling
- Team ownership and access boundaries

Your job:

1. **Pick the layout** — recommend a directory-per-environment structure with a shared `modules/` directory, or a live/root-config pattern, and justify it.
2. **State boundaries** — split state per environment and per logical system so plans are fast and blast radius is small; document the backend key per stack.
3. **Config reuse** — show how environments consume the same modules with different `*.tfvars`, keeping drift between envs visible and intentional.
4. **Promotion flow** — describe how a change flows dev → staging → prod (same module version, different vars) and how to pin module versions per environment.
5. **Cross-stack wiring** — where one stack needs another's outputs, note the remote-state or data-source boundary.
6. **Access & CI** — map which pipeline/role can apply which environment; prod should require stronger approval.

Output as: (a) an annotated directory tree, (b) the per-env backend/state map, (c) a promotion workflow, (d) an access model.

Keep each environment in its own state so a mistake in dev cannot plan changes into prod; share modules, never share state across environments.

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

More OpenTofu prompts & error guides

Browse every OpenTofu prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.