$npx -y skills add thomast1906/github-copilot-agent-skills --skill terraform-provider-upgradeSafe Terraform provider upgrades with automatic resource migration, breaking change detection, and state management using moved blocks. Use when upgrading provider versions, handling removed resources, migrating deprecated syntax, or performing major version upgrades.
| 1 | # Terraform Provider Upgrade Skill |
| 2 | |
| 3 | This skill provides a comprehensive workflow for safely upgrading Terraform providers with automatic resource migration, breaking change detection, and proper state management. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | - **Upgrading provider versions** (especially major versions) |
| 8 | - **Handling removed or deprecated resources** |
| 9 | - **Migrating between resource types** (e.g., `azurerm_sql_*` → `azurerm_mssql_*`) |
| 10 | - **Detecting and resolving breaking changes** |
| 11 | - **Replacing deprecated provider properties** |
| 12 | - **Managing Terraform state during upgrades** |
| 13 | |
| 14 | ## Determining Breaking vs Non-Breaking Changes |
| 15 | |
| 16 | ### Version Change Analysis |
| 17 | |
| 18 | **Use MCP tools to understand the scope:** |
| 19 | |
| 20 | ```bash |
| 21 | # Step 1: Get current and latest versions |
| 22 | mcp_terraform_get_latest_provider_version(namespace="hashicorp", name="azurerm") |
| 23 | # Current: 3.117.0, Latest: 4.51.0 → Major version change (likely breaking) |
| 24 | # Current: 3.117.0, Latest: 3.118.0 → Minor version change (likely non-breaking) |
| 25 | # Current: 3.117.0, Latest: 3.117.1 → Patch version (non-breaking) |
| 26 | |
| 27 | # Step 2: Discover available guide names |
| 28 | mcp_terraform_get_provider_capabilities(namespace="hashicorp", name="azurerm", version="latest") |
| 29 | |
| 30 | # Step 3: Get the provider_doc_id for the upgrade guide |
| 31 | mcp_terraform_search_providers(provider_namespace="hashicorp", provider_name="azurerm", service_slug="4.0-upgrade-guide", provider_document_type="guides", provider_version="latest") |
| 32 | |
| 33 | # Step 4: Fetch the upgrade guide content |
| 34 | mcp_terraform_get_provider_details(provider_doc_id="<id-from-search_providers>") |
| 35 | ``` |
| 36 | |
| 37 | ### Non-Breaking Changes (Auto-Apply) |
| 38 | |
| 39 | **Characteristics:** |
| 40 | - Minor or patch version updates (e.g., `3.117.0` → `3.118.0` or `3.117.1`) |
| 41 | - No removed resources |
| 42 | - No required argument changes |
| 43 | - Backward-compatible deprecations with drop-in replacements |
| 44 | - New optional arguments or bug fixes |
| 45 | |
| 46 | **Action:** |
| 47 | 1. Update version constraints in `versions.tf` |
| 48 | 2. Apply backward-compatible deprecation replacements if any |
| 49 | 3. Commit changes without detailed documentation |
| 50 | 4. Brief commit message: `chore: upgrade azurerm provider to v3.118.0` |
| 51 | |
| 52 | ### Breaking Changes (Apply + Document) |
| 53 | |
| 54 | **Characteristics:** |
| 55 | - Major version updates (e.g., `3.x` → `4.x`) |
| 56 | - Removed resources requiring code migration |
| 57 | - Required argument changes (renames, type changes) |
| 58 | - Default value changes affecting behavior |
| 59 | - Authentication or provider configuration changes |
| 60 | |
| 61 | **Action:** |
| 62 | 1. Apply ALL code changes (resource migrations, moved blocks, argument updates) |
| 63 | 2. Create comprehensive documentation at repository root: `TERRAFORM_UPGRADE_BREAKING_CHANGES.md` |
| 64 | 3. Document what was done (not what needs to be done) |
| 65 | 4. Detailed commit message referencing documentation |
| 66 | |
| 67 | ### Using MCP Tools to Identify Breaking Changes |
| 68 | |
| 69 | **Key indicators from upgrade guide:** |
| 70 | - Sections titled "Removed Resources", "Breaking Changes", "Behavior Changes" |
| 71 | - Resources listed as "removed" or "superseded by" |
| 72 | - Arguments marked as "renamed", "removed", or "type changed" |
| 73 | - Default value changes that affect existing behavior |
| 74 | |
| 75 | ## Core Workflow |
| 76 | |
| 77 | ### 1. Inventory Current State |
| 78 | |
| 79 | **Objective:** Find all provider references and document current versions |
| 80 | |
| 81 | ```bash |
| 82 | # Search for all Terraform files |
| 83 | find . -name "*.tf" |
| 84 | |
| 85 | # Search for provider version constraints |
| 86 | grep -r "required_providers" --include="*.tf" |
| 87 | grep -r "version.*=" --include="versions.tf" |
| 88 | ``` |
| 89 | |
| 90 | **Document:** |
| 91 | - Current provider versions across all modules/environments |
| 92 | - Location of all provider version constraints |
| 93 | - Environments using the provider |
| 94 | |
| 95 | ### 2. Check Latest Versions |
| 96 | |
| 97 | **Use MCP Tool:** |
| 98 | ```bash |
| 99 | mcp_terraform_get_latest_provider_version(namespace="hashicorp", name="azurerm") |
| 100 | ``` |
| 101 | |
| 102 | **Compare:** |
| 103 | - Current version: `3.117.1` |
| 104 | - Latest version: `4.51.0` |
| 105 | - Gap: Major version upgrade (3.x → 4.x) |
| 106 | |
| 107 | ### 3. Research Breaking Changes |
| 108 | |
| 109 | **Step 1: Discover Available Guides** |
| 110 | ```bash |
| 111 | mcp_terraform_get_provider_capabilities( |
| 112 | namespace="hashicorp", |
| 113 | name="azurerm", |
| 114 | version="latest" |
| 115 | ) |
| 116 | ``` |
| 117 | |
| 118 | **Step 2: Get the provider_doc_id for the Upgrade Guide** |
| 119 | ```bash |
| 120 | mcp_terraform_search_providers( |
| 121 | provider_namespace="hashicorp", |
| 122 | provider_name="azurerm", |
| 123 | service_slug="4.0-upgrade-guide", |
| 124 | provider_document_type="guides", |
| 125 | provider_version="latest" |
| 126 | ) |
| 127 | ``` |
| 128 | |
| 129 | **Step 3: Fetch Upgrade Guide Content** |
| 130 | ```bash |
| 131 | mcp_terraform_get_provider_details( |
| 132 | provider_doc_id="<id-from-search_providers>" |
| 133 | ) |
| 134 | ``` |
| 135 | |
| 136 | **Analyze upgrade guide for:** |
| 137 | - ✅ **Removed resources** (resources that no longer exist) |
| 138 | - ✅ **Deprecated resources** (warnings only) |
| 139 | - ✅ **Breaking argument changes** (required fields, renamed fields, type |