Analyzes and visualizes resource dependencies in Terraform configurations, identifies circular dependencies, and suggests optimal resource ordering. This skill should be used when users need to understand resource relationships, troubleshoot dependency issues, optimize apply order, or refactor complex configurations.
View on GitHubarmanzeroeight/fastagent-plugins
terraform-toolkit
plugins/terraform-toolkit/skills/terraform-dependency-analyzer/SKILL.md
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/armanzeroeight/fastagent-plugins/blob/main/plugins/terraform-toolkit/skills/terraform-dependency-analyzer/SKILL.md -a claude-code --skill terraform-dependency-analyzerInstallation paths:
.claude/skills/terraform-dependency-analyzer/# Terraform Dependency Analyzer This skill helps analyze and optimize resource dependencies in Terraform configurations. ## When to Use Use this skill when: - Understanding resource relationships and dependencies - Troubleshooting circular dependency errors - Optimizing resource creation order - Refactoring complex configurations - Documenting infrastructure dependencies ## Dependency Types ### Implicit Dependencies Terraform automatically detects dependencies through resource attribute references: - Most common and preferred method - Created when one resource references another's attributes - Example: `subnet_id = aws_subnet.main.id` ### Explicit Dependencies Use `depends_on` only when implicit dependencies aren't sufficient: - Cross-resource timing requirements - Dependencies not expressed through attributes - Ensuring proper creation/deletion order - Should be used sparingly ## Analysis Workflow ### 1. Generate Dependency Graph ```bash # Create visual dependency graph terraform graph | dot -Tpng > graph.png # View as text terraform graph ``` ### 2. Identify Resource Relationships Parse configuration to map dependencies: - Read through resource definitions - Note attribute references between resources - Identify explicit `depends_on` declarations - Map out dependency chains ### 3. Check for Circular Dependencies **Common causes:** - Security groups with mutual ingress rules - Resources referencing each other's attributes - Module outputs creating circular references **Solution approaches:** - Break cycles using separate rule resources - Restructure resource relationships - Use data sources to break circular references ## Common Dependency Patterns ### VPC Infrastructure 1. VPC → Internet Gateway, Subnets 2. Subnets → NAT Gateway, Route Tables 3. Route Tables → Route Table Associations 4. Security Groups → EC2/RDS instances ### IAM Resources 1. IAM Role → IAM Policy Attachments 2. IAM Role → Resources using the role ### Database Setup 1. VPC, S