340-terraform

Guide Terraform and OpenTofu workflows through fmt, validate, plan, and apply.

Updated May 21, 2026
One-click install
npx skills add https://github.com/ulf1/trading-regime --skill 340-terraform
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 340-terraform
Source: https://github.com/ulf1/trading-regime/tree/main/.agent/skills/340-terraform
Command: npx skills add https://github.com/ulf1/trading-regime --skill 340-terraform

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill prevents risky infrastructure changes by guiding you through Terraform’s declarative workflow and state-safe practices, so you avoid plan drift, accidental replacements, and common HCL/provider pitfalls.

Core Features & Use Cases

  • Terraform-safe change workflow: write/edit HCL, format, validate, generate a plan, apply the exact plan, and commit lock/state-related inputs for reproducibility.
  • Refactoring and review guidance: interpret plan symbols (+, -, ~, -/+) and focus on the specific resources/attributes affected to minimize blast radius.
  • State and import correctness: use import blocks or terraform import to bring existing infrastructure under Terraform management instead of recreating it.
  • Provider/HCL gotchas: cover practical issues such as for_each key determinism, null vs empty strings, sensitive data handling, and provider version attribute changes.
  • Use-case examples: environment-per-directory structure (no workspaces), modular design principles, and testing/policy-as-code suggestions for catching issues before apply.

Quick Start

Use the 340-terraform skill to review your Terraform plan for potential force-replacements and tell you exactly what to change before you apply.

Frequently Asked Questions about 340-terraform

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely plan and apply Terraform changes to avoid accidental resource replacements?

To safely plan and apply Terraform changes, follow a contract-first workflow using fmt, validate, plan, and apply in order. Reviewing plan symbols like +, -, and ~ helps minimize blast radius and prevent accidental replacements.

Why does my Terraform plan show a force-replacement and how do I prevent it?

A Terraform plan shows force-replacements when attributes require destructive changes. Reviewing plan symbols like -/+ identifies affected resources, and adjusting HCL syntax or provider version attributes can prevent unnecessary replacements.

How do I import existing cloud infrastructure into Terraform state without recreating resources?

Import existing infrastructure into Terraform state using import blocks or the terraform import command. This brings existing cloud resources under Terraform management without recreating them, ensuring state and real-world infrastructure align.

What is the best way to structure Terraform environments and handle state management safely?

The best way to structure Terraform environments is using an environment-per-directory layout without workspaces. Safe state management requires no manual .tfstate edits and no secrets hardcoding in HCL files.

Can I use OpenTofu with the same HCL workflow and safety practices as Terraform?

Yes, OpenTofu uses the same HCL syntax and declarative workflow as Terraform. Applying safety practices like plan interpretation, state-security constraints, and fmt/validate/plan/apply ordering ensures safe OpenTofu infrastructure changes.

What are common Terraform HCL gotchas when using for_each and handling sensitive data?

Common Terraform HCL gotchas include ensuring for_each key determinism, distinguishing null versus empty strings, and handling sensitive data properly to avoid hardcoding secrets. Provider version attribute changes can also trigger unexpected plan drift.