Migrating from Terraform Provider v1.x to v2.0
Complete migration guide for upgrading from Azion Terraform Provider v1.x (API v3) to v2.0 (API v4). Includes breaking changes, resource mapping, and configuration examples.
This guide provides detailed instructions for migrating from Azion Terraform Provider v1.x (API v3) to v2.0 (API v4). Follow the steps below to ensure a smooth transition.
Migration Overview
Terraform Provider v2.0 represents a major version that migrates to Azion API v4. This version introduces new resources and removes deprecated ones to align with the new API architecture.
Key Changes
| Aspect | v1.x (API v3) | v2.0 (API v4) |
|---|---|---|
| API Version | Azion API v3 | Azion API v4 |
| Domain Management | azion_domain resource | azion_workload and azion_workload_deployment resources |
| Origin Management | azion_edge_application_origin resource | azion_connector resource |
| Functions | azion_edge_function resource | azion_function resource |
| Custom Pages | Not available | azion_custom_page resource |
Version Compatibility
| Terraform Provider Version | API Version | Status |
|---|---|---|
| 1.41.0 and earlier | API v3 | Deprecated |
| 2.0.0 and later | API v4 | Current |
Before You Begin
Before starting the migration process, make sure you’ve completed the following preparations.
Prerequisites
- Terraform: Version 1.0 or later installed
- Azion Account: Valid account with API v4 access
- Personal Token: A valid personal token with appropriate permissions
- Backup: A complete backup of your current Terraform state and configurations
Configuration Backup
Create a backup of your current Terraform configuration and state files before making any changes:
Pin Your Version
If you need to remain on v1.x temporarily, pin the provider version:
Version 1.41.0 and earlier no longer receive updates or bug fixes. Plan your migration to v2.0 as soon as possible.
Breaking Changes
This section details the breaking changes between v1.x and v2.0.
Removed Resources
The following resources and data sources were removed in v2.0:
| Resource | Status | Replacement |
|---|---|---|
azion_domain | Removed | Use azion_workload and azion_workload_deployment |
azion_domains (data source) | Removed | Use azion_workloads data source |
azion_edge_application_origin | Removed | Use azion_connector |
azion_edge_applications_origins (data source) | Removed | Use azion_connectors data source |
Renamed Resources
| v1.x Resource | v2.0 Resource | Notes |
|---|---|---|
azion_edge_function | azion_function | Resource renamed to align with new product naming |
New Resources in v2.0
| Resource | Description |
|---|---|
azion_workload | Manage Azion workloads (replaces domain management) |
azion_workload_deployment | Manage workload deployments |
azion_connector | Manage Azion connectors (replaces origin management) |
azion_custom_page | Manage custom pages |
Unchanged Resources
The following resources remain available with their original names:
| Resource | Description |
|---|---|
azion_intelligent_dns_zone | DNS zones |
azion_intelligent_dns_record | DNS records |
azion_intelligent_dns_dnssec | DNSSEC settings |
azion_network_list | Network Lists |
azion_waf_rule_set | WAF rule sets |
azion_digital_certificate | Digital certificates |
azion_environment_variable | Environment variables |
Resource Mapping
This section provides detailed mapping between v1.x and v2.0 resources.
Domain to Workload Mapping
Domain management in v1.x has been replaced by a two-resource model in v2.0:
| v1.x (Domain) | v2.0 (Workload) |
|---|---|
azion_domain | azion_workload + azion_workload_deployment |
azion_domains (data source) | azion_workloads |
Key Differences:
- v1.x: A single
azion_domainresource managed the entire domain lifecycle - v2.0: Separation of concerns with
azion_workload(definition) andazion_workload_deployment(deployment)
Origin to Connector Mapping
Origin management has been replaced by connectors:
| v1.x (Origin) | v2.0 (Connector) |
|---|---|
azion_edge_application_origin | azion_connector |
azion_edge_applications_origins (data source) | azion_connectors |
Key Differences:
- v1.x: Origins were defined within the Applications context
- v2.0: Connectors are independent resources that provide more flexible integration options
Edge Function to Function Mapping
| v1.x | v2.0 |
|---|---|
azion_edge_function | azion_function |
azion_edge_functions (data source) | azion_functions data source |
Migration Examples
This section provides side-by-side configuration examples for migrating your Terraform resources.
Domain to Workload Migration
v1.x Configuration
v2.0 Configuration
Origin to Connector Migration
v1.x Configuration
v2.0 Configuration
Function Migration
v1.x Configuration
v2.0 Configuration
Complete Example: Application with Workload
v1.x Configuration
v2.0 Configuration
State Migration Steps
Follow these steps to migrate your Terraform state from v1.x to v2.0.
Step 1: Update Provider Version
Update your Terraform configuration to use Provider v2.0:
Step 2: Initialize the New Provider
Run Terraform init to download the new provider:
Step 3: Remove Deprecated Resources from State
Remove deprecated resources from your Terraform state:
Step 4: Update Configuration Files
Update your .tf files with the new resource configurations following the examples in the Migration Examples section.
Step 5: Import New Resources
Import your existing resources to the new resource types:
Step 6: Verify the Plan
Run a plan to verify expected changes:
Review the output carefully to ensure:
- No resources will be unexpectedly destroyed
- New resources will be created correctly
- Resource attributes are mapped correctly
Step 7: Apply Changes
Apply the changes:
Troubleshooting
This section covers common issues encountered during migration.
Common Errors and Solutions
Error: Provider Version Conflict
Solution: Make sure to specify the correct source and version. Run:
Error: Resource Type Not Found
Solution: This resource was removed in v2.0. Replace with azion_workload and azion_workload_deployment resources.
Error: State Migration Failed
Solution: The resource was already removed or doesn’t exist. Remove it from state:
Error: Import Not Found
Solution: Make sure the resource ID you’re importing exists in API v4. Some API v3 resources may have different IDs in API v4. Check the Azion Console to find the correct resource IDs.
Additional Resources
- Terraform Provider v2.0 Documentation
- Terraform Provider v1.x Documentation (Deprecated)
- Azion API v4 Documentation
- Terraform Registry - Azion Provider
Getting Help
If you encounter issues during migration:
- Review the Troubleshooting section
- Consult the Terraform Registry documentation
- Contact Azion Support through the Support Portal
- Visit the Azion Community for additional resources
Migration Checklist
Use this checklist to track your migration progress: