AZURE HEROES
  • Home-Updates
  • Blog
    • Azure Blog
    • Azure Heroes Events >
      • Azure Heroes Sessions #1
      • Azure Heroes Sessions #2
      • Azure Heroes Sessions #3
      • Azure Heroes Sessions #4
      • Azure Heroes Sessions #5
      • Azure Heroes Sessions #6
      • Azure Heroes Sessions #7
  • Who We Are!
  • eBooks
  • Azure All In One!
    • Azure Disk & Storage
    • Azure Network
    • Azure VPN
    • Azure VMs
  • Free Azure Support!
  • Contact Us
  • Events
    • Beginners Event
    • Developers Event
    • Special Event
    • Azure Workshop #4
    • Azure Workshop #5
    • Azure Workshop #6
    • Azure Workshop #7
    • Azure Workshop #8
    • Upcoming Events
  • Registration Form
  • Privacy Policy
  • Home-Updates
  • Blog
    • Azure Blog
    • Azure Heroes Events >
      • Azure Heroes Sessions #1
      • Azure Heroes Sessions #2
      • Azure Heroes Sessions #3
      • Azure Heroes Sessions #4
      • Azure Heroes Sessions #5
      • Azure Heroes Sessions #6
      • Azure Heroes Sessions #7
  • Who We Are!
  • eBooks
  • Azure All In One!
    • Azure Disk & Storage
    • Azure Network
    • Azure VPN
    • Azure VMs
  • Free Azure Support!
  • Contact Us
  • Events
    • Beginners Event
    • Developers Event
    • Special Event
    • Azure Workshop #4
    • Azure Workshop #5
    • Azure Workshop #6
    • Azure Workshop #7
    • Azure Workshop #8
    • Upcoming Events
  • Registration Form
  • Privacy Policy

Say Hello To Azure Terrafy

5/23/2022

1 Comment

 
Terraform is an infrastructure automation tool developed by HashiCorp four years
ago and it is written in the Go programming language. It is the first multi-cloud
infrastructure tool that allows the user to automate and set up infrastructure elements
from several cloud vendors simultaneously, as well as custom in-house solutions

Picture
let's start by the definition, so what is Azure Terrafy?

Azure Terrafy allows you to easily and quickly import your existing Azure infrastructure into Terraform HCL AND import it into your Terraform state. This has been one of the BIGGEST and coolest feature releases.
It’s great to adopt new working tools and practices for when we start a new project, but every single customer I work with wants to know how to manage their legacy infrastructure. The biggest challenge we face in ITOps is managing that legacy infrastructure.

 How To?

Note: Before using the tool I installed : Terraform, Golang, Choco on my Windows 10 Machine
1- To start using the aztfy tool, we need to install it locally. There are two options: the latest binaries or running the Go toolchain. You can run the Go toolchain using a single command
go install github.com/Azure/aztfy@latest
Picture
Picture
2- Once installed, run the aztfy command and specify the Azure resource group that you want to import
Note: Currently aztfy only supports importing at the resource group level)
Picture
  3- Aztfy will now begin the import process:
Picture
it found 394 resources in my resource group along with their dependencies.  From this view we can filter our results, show any errors/recommendations, or import our resources

4- Click W to start importing resources as it run, along with a progress bar

5- Once Azure Terrafy has completed, you can open your folder and see the newly generated template files:

Picture
6- The best way to validate the importing of your resources is by running ‘Terraform Plan
Picture
Congratulations! You’ve successfully imported your existing infrastructure in Azure into Terraform templates!

While this makes importing existing resources a breeze, there are some things to be conscious of at this point.

  • Naming conventions and reusability. While the templates are able to be used, naming conventions for your resources need to be reconfigured and all elements are defined in a very static way. You will need to manually edit and declare your variables to make the templates more scalable and reusable. 
  • State storage. When you import your Terraform files, the state is saved to the local file store, work needs to be done to store it remotely in a more secure way.
  • Code refactoring. Aztfy currently spits out the templates into one main.tf file, splitting out your templates into modules should be considered. You will need to spend some time in VSCode and make the new files more reusable and scalable.
  • Dependencies. Aztfy uses many of the dependencies in your resource group to map those out in the templates (see the 'depends_on' line declared in the main.tf above), much of that can be cleaned up once naming conventions and modules are implemented.
  • Import of Resource Groups. Currently, you can only import resource groups. Expect the product team to look into this, potentially making it available to import vNets or maybe even subscriptions!
1 Comment
Michael Aguirre link
10/7/2022 05:19:21 am

Raise message rich trial option course. Politics thank minute rest.
And relationship head. Herself let much cost center race.

Reply



Leave a Reply.

    Author

    Mohammad Al Rousan is a Microsoft MVP (Azure), Microsoft Certified Solution Expert (MCSE) in Cloud Platform & Azure DevOps & Infrastructure, An active community blogger and speaker. Al Rousan has over 8 years of professional experience in IT Infrastructure and very passionate about Microsoft technologies and products.

    Picture
    Picture
    Top 10 Microsoft Azure Blogs

    Archives

    November 2022
    October 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    May 2021
    February 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    June 2020
    April 2020
    January 2020
    July 2019
    June 2019
    May 2019
    February 2019
    January 2019

    Categories

    All
    AKS
    Azure
    Beginner
    CDN
    DevOps
    End Of Support
    Fundamentals
    Guide
    Hybrid
    License
    Migration
    Network
    Security
    SQL
    Storage
    Virtual Machines
    WAF

    RSS Feed

    Follow
    Free counters!
Powered by Create your own unique website with customizable templates.