Member-only story

Infrastructure as Code Tools Creating one VM in Azure

Park Sehun
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"

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response