IaC is a code (human readable) that deploys your infrastructure resources onto various platforms instead of managing them manually through a user interface. Provisioning infrastructure through software to achieve consistent and predictable environment.
- Terraform allows infrastructure to be expressed as code in a simple, human readable language called HCL (HashiCorp Configuration Language). It reads configuration files and provides an execution plan of changes, which can be reviewed for safety and then applied and provisioned.
- Extensible providers allow Terraform to manage a broad range of resources, including IaaS, PaaS, SaaS, and hardware services.
- The Azure Provider (azurerm) can be used to configure infrastructure in Microsoft Azure using the Azure Resource Manager API's. Official Terraform document --> https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
We will try to deploy a standalone Linux VM, below is the pictorial representation of what we will deploy
- In order to deploy these resources in Azure, clone the repo in Cloud shell(Azure)
- Move to the folder where the repo has been cloned. After that run
terraform init
command
- After that Validate (
terraform validate
) --> Plan(terraform plan
) --> Apply(terraform apply
)
- Once the resources are deployed, you can see the below mentioned message in your cloud shell
- As you would noticed we have create the private-public key using tls
We can save the private key in a file which will be used for login into the VM
Change the required permission and login using the below command as mentioned in the screenshot
- To clean up the resources created, just run
terraform destroy
command