Member-only story
Infrastructure as Code Tools Creating one VM in Azure
7 min readApr 15, 2023
Before choosing one of the IaC tools, you can taste them by having all samples code to do the same task. As most IaC tools are declarative languages so not significantly different between junior and senior engineers, how understandable and readable they are is very important because indeed IaC alternates the portal GUI visibilities with the code.
Terraform (Yaml)
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "example-resource-group"
location = "westus2"
}
resource "azurerm_virtual_network" "example" {
name = "example-vnet"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_subnet" "example" {
name = "example-subnet"
address_prefixes = ["10.0.1.0/24"]
virtual_network_name = azurerm_virtual_network.example.name
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_network_interface" "example" {
name = "example-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_configuration {
name = "example-config"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_virtual_machine" "example" {
name = "example-vm"…