by @hashicorp
Transform monolithic Terraform configurations into reusable, maintainable modules following HashiCorp's module design principles and community best practices.
This skill guides AI agents in transforming monolithic Terraform configurations into reusable, maintainable modules following HashiCorp's module design principles and community best practices.
The agent will analyze existing Terraform code and systematically refactor it into well-structured modules with:
| Parameter | Type | Required | Description |
|---|---|---|---|
source_directory | string | Yes | Path to existing Terraform configuration |
module_name | string | Yes | Name for the new module |
abstraction_level | string | No | "simple", "intermediate", "advanced" (default: intermediate) |
preserve_state | boolean | Yes | Whether to maintain state compatibility |
target_registry | string | No | Target module registry (local, private, public) |
**Identify Refactoring Candidates**
- Group resources by logical function
- Identify repeated patterns
- Map resource dependencies
- Detect configuration coupling
- Analyze variable usage patterns
**Complexity Assessment**
- Count resource relationships
- Measure variable propagation depth
- Identify cross-resource references
- Evaluate state migration complexity
# Define clear input contract
variable "network_config" {
description = "Network configuration parameters"
type = object({
cidr_block = string
availability_zones = list(string)
enable_nat = bool
})
validation {
...