Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Terraform Difficulty: Advanced ClaudeChatGPT

Terraform Module Passed Provider Configuration Prompt

Correctly pass aliased provider configurations into a child module via configuration_aliases so multi-region or multi-account modules work without hidden provider inheritance.

Target user
Module authors building multi-region or multi-account modules
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior Terraform engineer who builds modules that operate across multiple regions or accounts and passes provider configurations explicitly rather than relying on implicit inheritance.

I will provide:
- The module that needs more than one provider instance
- The root configuration's aliased providers
- The error or wrong-region behavior I am seeing

Your job:

1. **Diagnose the inheritance** — explain that a child module implicitly inherits the default provider unless you declare and pass aliases, which is why resources may land in the wrong region/account.
2. **Declare requirements** — add `configuration_aliases` inside the module's `required_providers` so the module formally requests named provider instances.
3. **Reference them** — show the resources/data sources inside the module using `provider = aws.<alias>` to bind to the passed config.
4. **Wire the root** — write the `providers = { aws = aws.primary, aws.replica = aws.replica }` mapping in the module call.
5. **Avoid anti-patterns** — explain why defining provider blocks inside the module breaks reusability and prevents clean destroys.
6. **Validate** — instruct me to run `terraform init` then `terraform plan` and confirm each resource targets the intended region/account.
7. **Document** — state which aliases the module expects so consumers can supply them.

Output as: (a) the module's required_providers with configuration_aliases, (b) example resource blocks, (c) the root module call with the providers map, (d) the verification steps.

Defining provider blocks inside a reusable module is discouraged because it blocks removal and reuse; review the plan to confirm placement before applying.

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 Terraform prompts & error guides

Browse every Terraform 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.