- Notifications
You must be signed in to change notification settings - Fork198
A tool to bring existing Azure resources under Terraform's management
License
Azure/aztfexport
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A tool to bring your existing Azure resources under the management of Terraform.
Azure Export for Terraform exports supported resources into Terraform state and generate the corresponding Terraform configuration. Both the Terraform state and configuration are expected to be consistent with the resources' remote state, i.e.,terraform plan
shows no diff. The user then is able to use Terraform to manage these resources.
It supports both theTerraform AzureRM provider and theTerraform AzAPI provider.
The Terraform configurations generated byaztfexport
are not meant to be comprehensive and do not ensure that the infrastructure can be fully reproduced from said generated configurations. For details, please seelimitations).
Precompiled binaries and Window MSI are available atReleases.
go install github.com/Azure/aztfexport@latest
winget install aztfexport
brew install aztfexport
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 9dnf install -y https://packages.microsoft.com/config/rhel/${ver}/packages-microsoft-prod.rpm
Install:
dnf install aztfexport
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.04apt-add-repository https://packages.microsoft.com/ubuntu/${ver}/prod
Install:
apt-get install aztfexport
yay -S aztfexport
aztfexport
requires aterraform
executable installed in the$PATH
with version>= v0.12
.
aztfexport
leveragesaztft
to identify the Terraform resource type corresponding to an Azure resource ID. Then it runsterraform import
under the hood to import each resource. Afterwards, it runstfadd
to generate the Terraform HCL code for each imported resource.
Read theAzure Export documentation which covers scenarios and usage.
aztfexport
will create a configuration file at$HOME/.aztfexport/config.json
. This file is aim to be managed by commandaztfexport config [subcommand]
, which includes following subcommands:
get
: Get a config itemset
: Set a config itemshow
: Show the full configuration
Currently, the following config items are supported:
installation_id
: A UUID created on first run. If there is Azure CLI or Azure Powershell installed on the current machine, the UUID will be the same value among these tools. Otherwise, a new one will be created. This is used as an identifier in the telemetry trace.telemetry_enabled
: Enables telemetry. We use telemetry to identify issues and areas for improvement, in order to optimize this tool for better performance, reliability, and user experience. If you wish to disable our telemetry, set this to false.
Visitthis page on the Azure Export for Terraform documentation that discusses the currently known limitations of the tool.
- The aztfexport Github Page: Everything about aztfexport, including comparisons with other existing import solutions.
- aztft: A Go program and library for identifying the correct Terraform AzureRM provider resource type on the Azure resource id.
- tfadd: A Go program and library for generating Terraform configuration from Terraform state.
About
A tool to bring existing Azure resources under Terraform's management