azapi2azurerm
Introduction
This tool is used to migrate resources from terraform azapi
provider to azurerm
provider.
Install
From Release
Precompiled binaries and Window MSI are available at Releases.
For Mac OS users, you need to run the following command to remove the quarantine flag.
xattr -d com.apple.quarantine azapi2azurerm
From Package Manager
dnf (Linux)
Supported versions:
- RHEL 8 (amd64, arm64)
- RHEL 9 (amd64, arm64)
-
Import the Microsoft repository key:
rpm --import https://packages.microsoft.com/keys/microsoft.asc
-
Add packages-microsoft-com-prod
repository:
ver=8 # or 9
dnf install -y https://packages.microsoft.com/config/rhel/${ver}/packages-microsoft-prod.rpm
-
Install:
dnf install azapi2azurerm
apt (Linux)
Supported versions:
- Ubuntu 20.04 (amd64, arm64)
- Ubuntu 22.04 (amd64, arm64)
-
Import the Microsoft repository key:
curl -sSL https://packages.microsoft.com/keys/microsoft.asc > /etc/apt/trusted.gpg.d/microsoft.asc
-
Add packages-microsoft-com-prod
repository:
ver=20.04 # or 22.04
apt-add-repository https://packages.microsoft.com/ubuntu/${ver}/prod
-
Install:
apt-get install azapi2azurerm
AUR (Linux)
yay -S azapi2azurerm
Command Usage
PS C:\Users\henglu\go\src\github.com\Azure\azapi2azurerm> azapi2azurerm.exe
Usage: azapi2azurerm [--version] [--help] <command> [<args>]
Available commands are:
migrate Migrate azapi resources to azurerm resources in current working directory
plan Show azapi resources which can migrate to azurerm resources in current working directory
version Displays the version of the migration tool
- Run
azapi2azurerm plan
under your terraform working directory,
it will list all resources that can be migrated from azapi
provider to azurerm
provider.
The Terraform addresses listed in file azapi2azurerm.ignore
will be ignored during migration.
2022/01/25 14:34:46 [INFO] searching azapi_resource & azapi_update_resource...
2022/01/25 14:34:55 [INFO]
The tool will perform the following actions:
The following resources will be migrated:
azapi_resource.test2 will be replaced with azurerm_automation_account
azapi_update_resource.test will be replaced with azurerm_automation_account
The following resources can't be migrated:
azapi_resource.test: input properties not supported: [], output properties not supported: [identity.principalId, identity.type, identity.tenantId]
The following resources will be ignored in migration:
- Run
azapi2azurerm migrate
under your terraform working directory,
it will migrate above resources from azapi
provider to azurerm
provider,
both terraform configuration and state.
The Terraform addresses listed in file azapi2azurerm.ignore
will be ignored during migration.
Examples
There're some examples to show the migration results.
- case1 - basic
- case2 - for_each
- case3 - nested block
- case4 - count
- case5 - nested block patch
- case6 - meta argument
- case7 - ignore
Features
- Support resource
azapi_resource
migration
- Support resource
azapi_update_resource
migration
- Support meta-argument
for_each
- Support meta-argument
count
- Support meta-argument
depends_on
, lifecycle
and provisioner
- Support dependency injection in array and primitive value.
- Support dependency injection in Map and other complicated struct value.
- Support user input when there're multiple/none
azurerm
resource match for the resource id
- Support migration based on
azurerm
provider's property coverage
- Support ignore terraform addresses listed in file
azapi2azurerm.ignore
- Support data source
azapi_resource
migration.
Known limitations
- References to local variables can't be migrated.
- Usage of
dynamic
can't be migrated.
- Update resource used to manage CMK can't be migrated.
Credits
We wish to thank HashiCorp for the use of some MPLv2-licensed code from their open source project terraform-plugin-sdk.