terraform-patterns

Manage Terraform infrastructure with import, dynamic resources, state locking, and drift detection.

Updated Feb 26, 2026
One-click install
npx skills add https://github.com/engineers-hub-ltd-in-house-project/eh-skills --skill terraform-patterns-engineers-hub-ltd-in-house-project
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-patterns
Source: https://github.com/engineers-hub-ltd-in-house-project/eh-skills/tree/main/skills/iac/terraform-patterns
Command: npx skills add https://github.com/engineers-hub-ltd-in-house-project/eh-skills --skill terraform-patterns-engineers-hub-ltd-in-house-project

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides practical, battle-tested patterns for managing Terraform effectively, addressing common challenges in real-world infrastructure as code deployments.

Core Features & Use Cases

  • Resource Import: Safely bring existing infrastructure under Terraform management.
  • Conditional & Dynamic Resources: Create flexible infrastructure configurations using count, for_each, and dynamic blocks.
  • Drift Detection & State Management: Implement robust workflows for monitoring and maintaining infrastructure consistency.
  • Use Case: When migrating existing AWS resources to Terraform, use the import patterns to ensure a smooth transition without service disruption.

Quick Start

Use the terraform-patterns skill to import an existing AWS S3 bucket named 'my-existing-bucket' into Terraform.

Frequently Asked Questions about terraform-patterns

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

FAQPage Schema
How do I import existing AWS resources into Terraform without service disruption?

How do I import existing AWS resources into Terraform without service disruption? You use specific resource import patterns to bring unmanaged infrastructure under state management without causing service disruption. This ensures a smooth transition when migrating existing AWS resources to IaC.

What is the best way to detect and manage drift in Terraform state?

You implement robust drift detection workflows to monitor and maintain infrastructure consistency. This identifies manual changes outside Terraform, allowing you to reconcile state and live infrastructure safely.

How do I use count and for_each for conditional resource creation in Terraform?

You apply conditional and dynamic resource patterns using count, for_each, and dynamic blocks to create flexible configurations. This enables dynamic infrastructure deployments based on variable inputs.

How do I refactor Terraform resources safely using moved blocks?

You use moved blocks to explicitly track resource relocations within your configuration. This updates the state mapping without destroying and recreating the actual infrastructure during plan and apply workflows.

Can I manage complex infrastructure configurations with dynamic blocks in Terraform?

Yes, dynamic blocks allow you to generate nested configuration structures programmatically. This pattern simplifies managing complex infrastructure as code by iterating over variables to define repeatable settings.