Terraform

Terraform

"The Definition of IAC"

"IAC, which stands for Infrastructure as Code, refers to the process of managing infrastructure using files instead of manually configuring resources through a user interface. In this context, a resource can be any element of infrastructure within a particular environment, such as a virtual machine, security group, network interface, and more.

Terraform is a tool designed for the safe and efficient creation, modification, and versioning of infrastructure. It can handle various existing and popular service providers, in addition to custom in-house solutions.

Configuration files provide Terraform with the necessary information to deploy a single application or even an entire data center. Terraform creates an execution plan outlining the steps it will take to reach the desired infrastructure state, and then it executes those steps to build the specified infrastructure. As the configuration evolves, Terraform can identify changes and generate incremental execution plans that can be implemented.

The range of infrastructure that Terraform can manage includes both foundational components like compute instances, storage, and networking, as well as higher-level elements such as DNS entries and SaaS features."

 

MANAGE INFRASTRUCTURE

  • VARIABLES Types

What we can use as variables are Strings, Numbers, Boolean, List, or Maps. We can define values as default as well. Examples: 

variable "RDP_Port" {
    type = number
    default = 3389
}

or 

variable "resource_group_location" {
  default     = "eastus"
  description = "Location of the resource group."
}

or

variable "enable" {
    default = true
}

Note: that numbers or integers do not require double quotes in Terraform, as Terraform automatically converts numbers and boolean values to strings when necessary. For instance, "10" and 10 are both valid.

  • VARIABLES LIST

A list is the same as an array, allowing us to store multiple values. It's important to remember that the first value is located at position 0. For instance, to access the value at position 0: