Git_TerraCLI
Source: Dev.to
This is a submission for the GitHub Copilot CLI Challenge. I built a Copilot CLI Agent that automatically refactors Terraform deprecations and opens pull requests using the Model Context Protocol (MCP). No more manual upgrades, missed warnings, or broken pipelines.
The solution integrates:
- GitHub Copilot CLI Agent (custom‑named copilot)
- Terraform MCP Server
- Azure DevOps Pipelines
- Automatic PR creation in Azure Repos
- Continuous
azurermprovider maintenance
Result: Infrastructure maintenance becomes autonomous.
🧩 The Problem
Terraform projects—especially those using the Azure provider—accumulate technical debt quickly. Each new release of the HashiCorp azurerm provider introduces:
- Deprecated resources
- Renamed arguments
- Behavioral changes
- Breaking updates
- Plan failures over time
Manually fixing these across dozens of .tf files is:
- ❌ Time‑consuming
- ❌ Error‑prone
- ❌ Often postponed
- ❌ Risky in production
💡 The Solution
I engineered a fully autonomous remediation agent that:
- Detects outdated provider versions
- Upgrades
azurermto the latest compatible version - Runs
terraform plan - Uses MCP to fetch exact replacements for deprecated fields
- Refactors code safely
- Validates changes
- Creates a pull request automatically
All of this runs inside an Azure Pipeline with zero human intervention. Using the GitHub Copilot CLI in agent mode transformed it from a code‑generation tool into an autonomous developer.
Highlights
- Context Awareness: The agent understands repository structure, Terraform semantics, pipeline environment, and required workflow steps.
- Speed of Development: Tasks that normally take hours are reduced to minutes (writing complex pipeline logic, handling provider upgrades, creating PR automation, integrating MCP).
🧠 From Assistant → Agent
This project demonstrates the shift from AI as a helper to AI as a teammate that executes tasks end‑to‑end. The agent enables:
- 🛡️ Continuous compliance with provider updates
- ⚡ Faster upgrade cycles
- 🧹 Reduced technical debt
- 🤖 Autonomous DevOps operations
- 🏢 Enterprise scalability
🔮 Future Improvements
Planned enhancements include:
- Slack / Teams notifications on PR creation
- Multi‑provider support (AWS, GCP)
- Drift detection integration
- Security policy checks
- Automatic merge on green validation
- ChatOps commands to trigger updates
🧪 Key Technologies Used
- GitHub Copilot CLI (Agent Mode)
- Terraform
- Model Context Protocol (MCP)
- Azure DevOps Pipelines
- Docker
- Azure CLI
- PowerShell
- Pull Request automation within pipelines