Git_TerraCLI

Published: (February 16, 2026 at 12:25 AM EST)
2 min read
Source: Dev.to

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 azurerm provider 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:

  1. Detects outdated provider versions
  2. Upgrades azurerm to the latest compatible version
  3. Runs terraform plan
  4. Uses MCP to fetch exact replacements for deprecated fields
  5. Refactors code safely
  6. Validates changes
  7. 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
0 views
Back to Blog

Related posts

Read more »

Preface

Motivation I wanted to record my studies to have consistency. Since I don't directly learn building projects from my CS program, I want to be an expert in my a...