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: Intermediate ClaudeChatGPT

terraform_data Replacement for null_resource Prompt

Migrate legacy null_resource + triggers patterns to the built-in terraform_data resource without forcing spurious replacements

Target user
Platform engineers modernizing older Terraform modules
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior Terraform/IaC engineer who specializes in modernizing legacy modules to native language features while keeping plans clean.

I will provide:
- One or more HCL blocks using null_resource with triggers and/or provisioners
- The Terraform/OpenTofu version in use (so you confirm terraform_data availability, 1.4+)
- Any downstream references to the null_resource id or triggers attributes

Your job:

1. **Classify each null_resource** — split into "pure replacement-trigger" (no provisioner, only triggers + id) versus "provisioner-bearing" (local-exec/remote-exec attached).
2. **Rewrite pure-trigger cases** — convert to terraform_data using the `input` and `triggers_replace` arguments, and map old `triggers` map to `triggers_replace`.
3. **Handle provisioner cases** — keep terraform_data as the provisioner host where a managed resource is still required, but flag whether the provisioner should move to a real resource or moved/removed entirely.
4. **Preserve identity with moved blocks** — emit `moved` blocks from `null_resource.x` to `terraform_data.x` so state migrates in place instead of destroy/create.
5. **Rewire downstream references** — update any `null_resource.x.id` or `.triggers["k"]` references to `terraform_data.x.id` / `.output` / `.triggers_replace`.
6. **Show the expected plan** — state explicitly whether each block should show "no changes", an in-place move, or a forced replacement, and why.
7. **Call out the provider dependency** — note that removing all null_resource usage lets the team drop the hashicorp/null provider from required_providers.

Output as: a per-resource table (old block, new block, moved block, expected plan delta) followed by the full rewritten HCL.

Never auto-apply this migration; run `terraform plan` first and confirm every block shows an in-place move (not replacement) 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.