What is Terraform?
Terraform is an Infrastructure as Code (IaC) software tool offered by HashiCorp. You can provision and manage your infrastructure both on-premises and in the cloud with it.
How to execute Terraform Scripts?
Prerequisite
1. You need an Azure Portal account
2. Install Azure CLI on your local system. Download the installer from the below link
Azure CLI Installer
3. Azure Login on command prompt run (az login) command
4. Install Terraform. Download the installer from the below link. Download AMD64 for 64-bit system. Terraform Download
Let's create a small script to create a resource Group in the Azure portal.
Step 1: Create a Terraform file to create a resource group. Paste the below script into the new file and the name should be anyname.tf
provider "azurerm" { version = "~>2.0" features {}}
resource "azurerm_resource_group" "terraform1" { name = "terraform1" location = "eastus"}
provider "azurerm" {
version = "~>2.0"
features {}
}
resource "azurerm_resource_group" "terraform1" {
name = "terraform1"
location = "eastus"
}
Place the file in any drive. I have placed the file in the D drive. Below is my file. My Resource group name is terraform1. You can write any name.
Step 2: Intialize Terraform.
My file is on D drive. So I have executed the command from D drive.
terraform init
No comments:
Post a Comment