Issue
Terraform plan execution failed with four critical error categories:
- Undeclared resources in
outputs.tfreferencing non-existent subnets. - Active firewall resource referencing a commented-out subnet.
- Missing module variables for Azure Container Registry (ACR) configuration.
- Invalid resource type for ACR georeplications.
Culprit
Subnet Reference Mismatches
Earlier optimizations commented out subnet declarations but failed to update corresponding references, leading to broken outputs and firewall configurations.
Module Variable Gaps
The ACR module required variables (allowed_ip_ranges, allowed_subnet_ids) that were not defined or passed from the root module.
Resource Type Typo
A pluralized resource type was incorrectly used for ACR georeplications, causing syntax errors.
Solution
Subnet Reference Fixes
Updated the outputs to reference the correct subnet resources and removed invalid references to ensure consistency.
ACR Module Configuration
Added missing variables in the root module and defined them in the variables file to ensure ACR configuration completeness.
Resource Type Correction
Fixed the ACR georeplication resource type from plural to singular to align with Terraform syntax.
Validation and Security
Implemented validation steps and change control procedures to maintain infrastructure stability and security, ensuring no unintended data deletion or configuration changes.
This solution resolved the Terraform configuration errors, enabling successful infrastructure deployment while maintaining cost-optimized configurations.