terraform local variable
variable conditions
terraform null resource
Referhere
Ex: created multiple resources i need that details
provisioner
- copy files to existing ec2 instance
- run commands or do patching ec2 instance
Azure with terraform
Pre-requests:
- azure cli
- terraform
- git
Local & cicd
az login service prinical
azure providers
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=5.0.0"
}
}
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
}
create resource group
### variables
variable "resource_group_names" {
type = list(string)
default = [ "devops", "demo-2" ]
}
variable "locations" {
type = list(string)
default = [ "Central India", "Central US" ]
}
### resources
resource "azurerm_resource_group" "rg" {
count = length(var.resource_group_names)
name = var.resource_group_names[count.index]
location = var.locations[count.index]
managed_by = "devops"
tags = {
env = "prod"
}
}
try task in azure
- create resource_group
- vnet and subnets
- create public ip
