Migrate from provider v1.x to v2.0
Move a Terraform configuration and its state from Azion Terraform Provider v1.x on API v3 to v2.0 on API v4.
You can move a Terraform configuration and its state from Azion Terraform Provider v1.x, which calls Azion API v3, to v2.0, which calls Azion API v4. To keep a configuration on v1.x instead, refer to Azion Terraform Provider v1.x (API v3).
Provider v2.0 is a major version. It adds resources and removes deprecated ones to match Azion API v4, so a v1.x configuration does not run on v2.0 unchanged.
Prerequisites
- Terraform 1.0 or later.
- An Azion account with access to Azion API v4.
- A personal token with the permissions your configuration needs.
- A list of the resources your configuration manages, with the ones v2.0 removes or renames marked. The tables in Resource changes in v2.0 on this page name them.
Back up the configuration and state
The migration removes resources from the Terraform state and imports them again under other types. Keep a copy of the configuration files and the state so you can return to the v1.x setup.
To back up the project and its state:
The ~/terraform-backup directory holds the configuration files and a copy of the state.
Pin the provider to v1.x
Each provider version line calls one Azion API version:
| Provider version | API version | Status |
|---|---|---|
| 1.41.0 and earlier | API v3 | Deprecated |
| 2.0.0 and later | API v4 | Current |
Version 1.41.0 is the last v1.x version. To keep running v1.x while you prepare the migration, pin the provider to it:
The next terraform init keeps the provider at 1.41.0.
Resource changes in v2.0
Provider v2.0 removes, renames, and adds resources. The four tables below list each v1.x resource and data source with its v2.0 counterpart. For every argument of a v2.0 resource, refer to the Terraform Registry.
Removed resources
Provider v2.0 has no resource or data source with these v1.x names:
| v1.x name (API v3) | Replacement in v2.0 |
|---|---|
azion_domain | azion_workload and azion_workload_deployment |
azion_domains (data source) | azion_workloads (data source) |
azion_edge_application_origin | azion_connector |
azion_edge_applications_origins (data source) | azion_connectors (data source) |
Renamed resources
These v1.x resources keep their role in v2.0 under another name. The v2.0 names follow the current product names:
| v1.x name (API v3) | v2.0 name |
|---|---|
azion_edge_function | azion_function |
azion_edge_functions (data source) | azion_functions (data source) |
azion_edge_application_main_setting | azion_application_main_setting |
azion_edge_application_cache_setting | azion_application_cache_setting |
azion_edge_application_rule_engine | azion_application_rule_engine |
azion_edge_application_edge_functions_instance | azion_application_functions_instance |
azion_edge_firewall_main_setting | azion_firewall_main_setting |
azion_edge_firewall_edge_functions_instance | azion_firewall_functions_instance |
Resources added in v2.0
Provider v2.0 adds four resources:
| Resource | What it manages |
|---|---|
azion_workload | Workloads. Replaces azion_domain together with azion_workload_deployment. |
azion_workload_deployment | Workload deployments. |
azion_connector | Connectors. Replaces azion_edge_application_origin. |
azion_custom_page | Custom pages. Provider v1.x has no resource for them. |
Unchanged resources
These resources keep their v1.x names in v2.0:
| Resource | What it manages |
|---|---|
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 |
Upgrade the provider to v2.0
The upgrade takes two changes: the version constraint in the configuration and the provider installed in the project.
To change the version constraint, set version to 2.0.0 in the required_providers block:
To download provider 2.0.0, run:
Terraform installs provider 2.0.0 in the project.
Remove the v1.x resources from the state
Remove the deprecated v1.x resources from the Terraform state before you import them under their v2.0 types.
To remove the domain, origin, and function entries from the Terraform state:
Replace example with the name each resource has in your configuration. The state no longer lists these resources, and the resources stay on your Azion account.
Update the configuration files
Rewrite each removed or renamed resource in your .tf files with its v2.0 type. The pairs below show a v1.x block and the v2.0 block that replaces it.
Replace a domain with a workload
In v1.x, one azion_domain resource managed the whole domain lifecycle. In v2.0, azion_workload holds the definition and azion_workload_deployment holds the deployment. For every argument of both resources, refer to Workloads resources.
The v1.x configuration:
The v2.0 configuration:
Replace an origin with a connector
In v1.x, an origin belonged to an application and took its edge_application_id. In v2.0, a connector is an independent resource. For every argument of azion_connector, refer to Connectors resources.
The v1.x configuration:
The v2.0 configuration:
Rename a function resource
The function resource keeps its arguments in v2.0: name, active, code, and json_args. Only the resource type changes, from azion_edge_function to azion_function.
The v1.x configuration:
The v2.0 configuration:
Migrate a complete configuration
A configuration with an application, an origin, a domain, and a function changes in four places: the application main setting takes its v2.0 name, a connector replaces the origin, a workload and a deployment replace the domain, and the function takes its v2.0 type. For the application resources, refer to Applications resources.
The v1.x configuration:
The v2.0 configuration:
Import the resources under their v2.0 types
The resources you removed from the state still exist on your Azion account. Import each one under its v2.0 resource type with terraform import <type>.<name> <id>.
To import the workload, connector, and function:
Replace each ID with the API v4 ID of the resource. An API v3 resource can have a different ID in API v4, so look the IDs up in Azion Console. The state lists the imported resources under their v2.0 types.
Review and apply the plan
A plan shows what Terraform changes before anything changes on your account.
To preview the changes, run:
In the plan output, confirm three things:
- No resource is destroyed that you expect to keep.
- The resources you expect to create appear in the plan.
- The attributes match the v2.0 arguments you set in the configuration.
To apply the changes, run the command in a test environment first:
Terraform manages the resources through provider 2.0.0 and Azion API v4. For errors during the migration, refer to Troubleshoot the Terraform Provider.
Clean up after the migration
After the apply, finish the migration in your project:
- Confirm that the migrated resources work on your Azion account.
- Update the CI/CD pipelines that run Terraform.
- Remove the v1.x code the configuration no longer uses.
- Update the project documentation and tell your team about the change.
- Archive the backups once the migration is confirmed.
The project runs on provider v2.0, with no v1.x resource left in the configuration or the state.