A tool to bring existing Azure resources under Terraform's management
Перейти к файлу
magodo d581f469e5
Update aztft to support populate logic app workflow's prop-like resources (#421)
2023-07-04 14:35:12 +08:00
.devcontainer Adding a devcontainer (#73) 2022-04-24 19:50:35 +08:00
.github/workflows Integrate `codeql` to CI (#271) 2022-10-24 12:40:34 +08:00
doc Single resource mode supports resource population and depedency 2022-09-23 17:12:13 +08:00
internal actually it is v1.5.0 2023-05-25 09:43:38 +08:00
pkg Resource mapping file will now be generated together with the `import.tf` that is the TF plannable import blocks 2023-05-16 11:48:10 +08:00
scripts/package rename in scripts folder 2023-03-06 12:12:14 +08:00
.gitignore Interactive mode: <kbd>del</kbd> can be used for reverting skip (#326) 2023-01-03 15:18:15 +08:00
.goreleaser.yml manual versioning for binary app 2021-08-29 09:35:42 +08:00
LICENSE Include in license file a copyright notice from the Hashicorp OSS project (#63) 2022-04-14 14:09:26 +08:00
Makefile Refactor: remove dependency on the v1.1.0-alpha terraform (#56) 2022-04-13 11:18:54 +08:00
README.md Add youtube video, remove previous demo video (#414) 2023-06-16 08:19:52 +08:00
SECURITY.md Microsoft mandatory file (#98) 2022-05-19 09:38:24 +08:00
azure-pipelines-ci.yml Integrate `credscan` to CI (#272) 2022-10-24 14:48:27 +08:00
azure-pipelines.yml PMC migration to vNext (#403) 2023-05-24 15:28:08 +08:00
command_before_func.go New CLI options: `--use-environment-cred`, `--use-managed-identiy-cred` and `--use-azure-cli-cred` to allow users to explicitly choose auth method instead of the default auth chain (#390) 2023-04-17 14:11:27 +08:00
command_before_func_test.go New CLI options: `--use-environment-cred`, `--use-managed-identiy-cred` and `--use-azure-cli-cred` to allow users to explicitly choose auth method instead of the default auth chain (#390) 2023-04-17 14:11:27 +08:00
flag.go Telemetry collect subscription ID (#389) 2023-04-25 09:00:00 +08:00
go.mod Update aztft to support populate logic app workflow's prop-like resources (#421) 2023-07-04 14:35:12 +08:00
go.sum Update aztft to support populate logic app workflow's prop-like resources (#421) 2023-07-04 14:35:12 +08:00
main.go Resource mapping file will now be generated together with the `import.tf` that is the TF plannable import blocks 2023-05-16 11:48:10 +08:00
version.go version no newline (#192) 2022-08-03 14:24:34 +08:00

README.md

Microsoft Azure Export for Terraform

A tool to bring your existing Azure resources under the management of Terraform.

Video (v0.12.0)

Video

Goal

Azure Export for Terraform exports resources that are supported by the Terraform AzureRM provider 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.

Non Goal

The Terraform configurations generated by aztfexport are not meant to be comprehensive and do not ensure that the infrastructure can be fully reproduced from said generated configurations. For details, please see limitations).

Install

From Release

Precompiled binaries and Window MSI are available at Releases.

From Go toolchain

go install github.com/Azure/aztfexport@latest

From Package Manager

Windows

winget install aztfexport

Homebrew (Linux/macOS)

brew install aztfexport

dnf (Linux)

Supported versions:

  • RHEL 8 (amd64, arm64)
  • RHEL 9 (amd64, arm64)
  1. Import the Microsoft repository key:

    rpm --import https://packages.microsoft.com/keys/microsoft.asc
    
  2. Add packages-microsoft-com-prod repository:

    ver=8 # or 9
    dnf install -y https://packages.microsoft.com/config/rhel/${ver}/packages-microsoft-prod.rpm
    
  3. Install:

    dnf install aztfexport
    

apt (Linux)

Supported versions:

  • Ubuntu 20.04 (amd64, arm64)
  • Ubuntu 22.04 (amd64, arm64)
  1. Import the Microsoft repository key:

    curl -sSL https://packages.microsoft.com/keys/microsoft.asc > /etc/apt/trusted.gpg.d/microsoft.asc
    
  2. Add packages-microsoft-com-prod repository:

    ver=20.04 # or 22.04
    apt-add-repository https://packages.microsoft.com/ubuntu/${ver}/prod
    
  3. Install:

    apt-get install aztfexport
    

AUR (Linux)

yay -S aztfexport

Prerequisites

aztfexport requires a terraform executable installed in the $PATH with version >= v0.12.

How it Works

aztfexport leverages aztft to identify the Terraform resource type corresponding to an Azure resource ID. Then it runs terraform import under the hood to import each resource. Afterwards, it runs tfadd to generate the Terraform HCL code for each imported resource.

Usage

Read the Azure Export documentation which covers scenarios and usage.

Config

aztfexport will create a configuration file at $HOME/.aztfexport/config.json. This file is aim to be managed by command aztfexport config [subcommand], which includes following subcommands:

  • get: Get a config item
  • set: Set a config item
  • show: 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.

Limitations

Visit this page on the Azure Export for Terraform documentation that discusses the currently known limitations of the tool.

Additional Resources

  • 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.