Powered by Microsoft Azure
https://www.facebook.com/troubleshootingazure

Import Existing Azure Resources into Terraform: aztfy

azure, cybersecurity, IT

Import Existing Azure Resources into Terraform: aztfy

Terraform, in case you aren’t aware of it !!

Terraform is an infrastructure as a code tool that enables you to define your data centre resources using high-level configuration language and provision them across multiple clouds. Terraform supports AWS, Azure, Google Cloud Platform, OpenStack, and more.

With Terraform, you can manage your Infrastructure as Code, meaning you can define your data center resources in version control and deploy them across multiple clouds with just a few clicks. Terraform makes it easy to provision and manage your cloud resources from a single platform.

If you’re looking for a way to simplify your cloud infrastructure management, Terraform is the perfect tool for the job.

Azure Terrafy enables users to quickly and easily import their existing Azure infrastructure into Terraform HCL, where they can then import it into Terraform.

You’ll need to satisfy some requirements before you can start using the tool.

Pre-requisites:

  • Install Golang: https://go.dev/
  • Install Terraform: https://learn.hashicorp.com/tutorials/terraform/install-cli
  • Install Chocolatey: https://chocolatey.org/install#individual

Install aztfy

This should take around a minute or two.

go install github.com/Azure/aztfy@latest

Ref. : https://github.com/Azure/aztfy

Login to Azure using AZ Cli:

Validate that you’re in the correct sub and can see the Resource Groups:

To import :

Type command aztfy rg <your resource group name>

This will be executed as below:

Press W to import:

It takes a while to import resources, but you will have a progress bar to show you the status.

The TF files are imported into the working directory:

And done:

Main.tf contains all the exported code:

Leave a Reply

Your email address will not be published.