• Home
  • Snehal’s Musings
  • Networking-and-SDN
  • Cloud-and-DevOps
  • Non-Technical
  • About Me
prosdn
  • Home
  • Snehal’s Musings
  • Networking-and-SDN
  • Cloud-and-DevOps
  • Non-Technical
  • About Me

Introduction to Terraform

Home Cloud Introduction to Terraform

Introduction to Terraform

Sep 27, 2023 | Posted by Snehal Patel | Cloud, DevOps, Snehal's Musings | 0 comments |

I had the privilege of being an NFD31 delegate in April 2023. HashiCorp gave a good demo on Infrastructure-as-Code (IaC) using Terraform. I had not used Terraform for some time, so this 3-part blog post series is my Terraform refresher.

 

This blog post focuses on Terraform basics.

 

What is Terraform?

Terraform is an Infrastructure-as-Code tool that lets you define your infrastructure in the cloud or on-prem in human-readable code that can be versioned and shared. You can deploy this code manually or use automation pipelines to create, update, or delete your infrastructure.

 

What are Terraform Providers?

Terraform has Providers for each platform. These Providers make API calls to their platform depending on the code’s intent, acting like a proxy for the API calls. For example, the Terraform Azure Provider will make an API call to Azure for VNET creation if that’s what you want your Terraform code to do. HashiCorp, vendors, and the community write thousands of providers to manage different types of resources. The providers are listed at https://registry.terraform.io/.

 

Terraform providers are written in Go. Terraform does not really know what to do with the target API, but the providers provide all the intelligence to orchestrate against an API. Providers are responsible for CRUD (Create, Update, Delete) operations and have the required logic and dependencies built in. For example, suppose you are trying to create a VNET in Azure. In that case, the Azure Provider knows that a VNET has to be created in an Azure Region and has to belong to a Resource Group and will handle the dependencies accordingly.

 

 

Imperative vs Declarative

It is important to note that Terraform uses a Declarative style of programming.

 

The imperative style focuses on “how” to achieve the target state, and you have to provide steps to be taken to reach from the current state to the target state. The declarative style focuses on “what” your end state is. You define the target state, and the tool automatically figures out how to achieve the target state. Terraform uses a declarative style, and tools like Ansible and Azure CLI use an imperative style. Imperative style does not keep track of the current state of your infrastructure, while declarative style does. Hence, Terraform has a state file with information about your infrastructure’s current state. We will learn more about the state file in the next blog.

 

Terraform Workflow

Terraform Workflow is a three-step process: Write, Plan, and Apply.

 

Write – Write your Terraform code to deploy your infrastructure using the specific providers as needed. This deployment could be for a single or multiple cloud providers. 

Plan – Terraform will create an implementation plan to exactly show the infrastructure resource that it will create, update, or delete. It will compare the current state of infrastructure with the intent of your code and present a plan, i.e., a diff.

Apply – Terraform will apply the changes, aka implement the plan it showed you in the previous step. Before applying, Terraform will resolve the dependencies as needed and then create the resources based on your code.

 

 

The next blog post will focus on basic Terraform code to create Azure Network resources.

 

References
HashiCorp – https://developer.hashicorp.com/terraform/intro

Terraform at NFD31 – https://techfieldday.com/appearance/hashicorp-presents-at-networking-field-day-31

 

 

 

0 Comments
0
Share

About Snehal Patel

I love building & running networks.

Leave a Reply

Your email is safe with us.
Cancel Reply

Recent Posts

  • Introduction to Terraform
  • Fortinet @ NFD20
  • Juniper intents to acquire Mist Systems
  • Networking Field Day 20 Is Here
  • Viptela/Cisco SD-WAN Components Overview

Recent Comments

  • Ravi Kashyap on Viptela/Cisco SD-WAN Components Overview
  • CCIE on Viptela/Cisco SD-WAN Components Overview
  • Roy W Hilliard on Azure Load Balancer v/s App Gateway v/s Traffic Manager

Archives

  • September 2023 (1)
  • June 2019 (1)
  • March 2019 (1)
  • February 2019 (1)
  • May 2018 (1)
  • December 2017 (1)
  • September 2017 (1)
  • May 2017 (1)
  • January 2017 (2)
  • April 2016 (1)

Categories

  • Cloud (2)
    • DevOps (1)
  • Networking-and-SDN (6)
  • Non-Technical (1)
  • Snehal's Musings (5)

Tags

AI Application Gateway Azure Cisco Cloud Fortinet GENEVE GLB GRE IKEless IPSEC iWAN Juniper L2VPN L3VPN Load Balancer Load Balancing Mist ML ML-and-AI NFD NFD20 non-technical NVGRE Overlay Overlays Public Cloud SD-WAN SDN SDWAN TFD Traffic Manager vBond vEdge Viptela vManage VPN vSmart VxLAN WLAN

Contact Me

Please drop me an email.

Send Message

© 2025 · ProSDN.

Prev