My Digital Garden

Using aztfy to import azure resources to Terraform

Using aztfy to import azure resources to Terraform

Introduction

The aztfy tool provides a means to import existing Azure resources into a local copy of the Terraform plan, AND into the defined Terraform state location.

Compared to Manual import of Azure Resources to Terraform it offers speed, but also these compromises:

  • resource names are machine-generated and don't convey any meaning
  • some resources won't be imported
  • amending an existing plan/state only works with a local backend

Installation

See the README

Usage

Typical use, to import all the resource in a resource group, into an empty folder:

aztfy resource-group <resource group name

Apaprently, if you are using local state you can update an existing plan / state by using the --append option

aztfy resource-group <resource group name> --append

  • caution, I haven't tried this as all the applications of Terraform I have use remote state in Terraform cloud

See also

Terrafy Existing Azure Resources : blog post by Kyle Ruddy (Hashicorp technical marketing)