What is Infrastructure as Code?
Prepare Workspace
- Install
- Terraform: (https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/azure-get-started)
- Azure CLI: open PowerShell as administrator
$ Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi - Visual Studio Code
- Terraform by HashiCorp
- Azure Terraform by Microsoft
- Azure Cloudshell (Powershell)
- Azure CLI tools
- Activate Azure Account
Open a powershell terminal and issue:
$ az login
Paste the following to the main.tf file:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "aingelrg1" {
name = "Session1"
location = "southeastasia"
}
On the terminal, follow through each of the commands
$ terraform init
Initialize terraform and check dependencies
$ terraform plan
Simulate what needs to happen in Azure
$ terraform apply
Execute the instruction in Azure. You need to type "yes" to confirm the execution.
$ terraform show
$ terraform destroy
Delete from Azure
You can checkout some samples at the following Git Repos:
https://github.com/hashicorp/terraform-provider-azurerm/tree/main/examples
https://github.com/aingelc12ell/jaira-terraform-azure/
No comments:
Post a Comment