Terraform

Guide Terraform state management, resource creation, and lifecycle rules.

3.1k|368|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/openocta/openocta --skill terraform-openocta
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Terraform
Source: https://github.com/openocta/openocta/tree/main/src/embed/skills/terraform
Command: npx skills add https://github.com/openocta/openocta --skill terraform-openocta

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps users avoid common and costly mistakes when using Terraform, ensuring infrastructure stability and preventing data loss or corruption.

Core Features & Use Cases

  • State Management: Guides on using remote backends, state locking, and safe state manipulation.
  • Resource Management: Explains the differences between count and for_each and how to manage resource lifecycles.
  • Dependency Handling: Clarifies implicit and explicit dependencies, including data sources and modules.
  • Use Case: Prevent accidental deletion of critical infrastructure by understanding prevent_destroy and create_before_destroy lifecycle rules.

Quick Start

Use the Terraform skill to learn about managing Terraform state safely.

Frequently Asked Questions about Terraform

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

FAQPage Schema
How do I prevent accidental deletion with Terraform lifecycle rules?

Terraform lifecycle rules prevent accidental deletion by using the `prevent_destroy` meta-argument to block resource destruction, while `create_before_destroy` ensures new resources are created before old ones are removed to maintain availability.

When should I use count vs for_each in Terraform resource creation?

Use `count` for Terraform resources when managing simple lists based on integer indices, and use `for_each` when creating resources from maps or sets to provide stable, unique identifiers that prevent unintended resource recreation.

What is the best way to manage Terraform state to avoid corruption?

The best way to manage Terraform state and avoid corruption is by configuring remote backends for centralized storage and enabling state locking to prevent concurrent operations from overwriting your infrastructure state files.

How do Terraform implicit and explicit dependencies affect resource ordering?

Terraform implicit dependencies are detected automatically from resource references, while explicit dependencies use the `depends_on` argument to force resource creation and destruction ordering when implicit detection is insufficient.

Does Terraform state locking work with all backend configurations?

Terraform state locking depends on backend capabilities; remote backends like S3 with DynamoDB support locking to prevent concurrent state writes, while local backends lack native locking and risk corruption during parallel execution.

Why does Terraform import fail to manage existing infrastructure correctly?

Terraform import fails when code does not match existing infrastructure because it only updates state without modifying resources; you must manually write matching resource configurations to prevent unexpected drift and recreation.