Azure Linux VM – Terraform

Terraform ile Azure Linux VM dağıtmak için aşağıdaki kodu kullanabilirsiniz.

resource "azurerm_resource_group" "msazureturkey" {
  name     = "msazureturkey-resources"
  location = "North Europe"
}

resource "azurerm_virtual_network" "msazureturkey" {
  name                = "msazureturkey-network"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.msazureturkey.location
  resource_group_name = azurerm_resource_group.msazureturkey.name
}

resource "azurerm_subnet" "msazureturkey" {
  name                 = "internal"
  resource_group_name  = azurerm_resource_group.msazureturkey.name
  virtual_network_name = azurerm_virtual_network.msazureturkey.name
  address_prefixes     = ["10.0.2.0/24"]
}

resource "azurerm_network_interface" "msazureturkey" {
  name                = "msazureturkey-nic"
  location            = azurerm_resource_group.msazureturkey.location
  resource_group_name = azurerm_resource_group.msazureturkey.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.msazureturkey.id
    private_ip_address_allocation = "Dynamic"
  }
}

resource "azurerm_linux_virtual_machine" "msazureturkey" {
  name                = "msazureturkey-machine"
  resource_group_name = azurerm_resource_group.msazureturkey.name
  location            = azurerm_resource_group.msazureturkey.location
  size                = "Standard_F2"
  admin_username      = "adminonder"
  network_interface_ids = [
    azurerm_network_interface.msazureturkey.id,
  ]

  admin_ssh_key {
    username   = "adminonder"
    public_key = file("~/.ssh/id_rsa.pub")
  }

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "16.04-LTS"
    version   = "latest"
  }
}

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

This site uses Akismet to reduce spam. Learn how your comment data is processed.