My Digital Garden

Importing Azure resources to Terraform

Importing Azure resources to Terraform

Overview

If you want to bring existing resources into Terraform control, you need to make changes in both the Terraform plan, and the matching state.

I have tried two approaches for doing this:

Adding uncontrolled resources to existing plan

I have had a couple of projects where the state was in Terraform Cloud, and I needed to bring into the plan some uncontrolled, pre-existing resources in Azure. The workaround approach I have got to so far for this is:

  • use aztfy to import the uncontrolled resources into an empty directory
  • manually copy the plan files into the project folder, adjusting resource names as required
  • for each added resource use the manual approach to import the resource into the remote state

See also

Other tools include: