Avi
Avi

Reputation: 1633

Terraform for Azure : storage_os_disk - invalid option

tried creating a new Azure VM and have specified options to create a empty storage OS Premium disk as below. Not sure what are the valid options to create an empty disk of size 100GB.

    resource "azurerm_virtual_machine" "main" {
      name                  = "${var.prefix}-vm"
      location              = "${azurerm_resource_group.main.location}"
      resource_group_name   = "${azurerm_resource_group.main.name}"
      network_interface_ids = ["${azurerm_network_interface.main.id}"]
      vm_size               = "Standard_D4s_v3"

      # Uncomment this line to delete the OS disk automatically when 
    deleting the VM
      # delete_os_disk_on_termination = true


      # Uncomment this line to delete the data disks automatically when 
    deleting the VM
      # delete_data_disks_on_termination = true

      storage_image_reference {
        publisher = "Canonical"
        offer     = "CentOS"
        sku       = "7.4"
        version   = "latest"
      }
      storage_os_disk {
        name              = "myosdisk1"
        caching           = "ReadWrite"
        create_option     = "Empty"
        managed_disk_type = "Premium_LRS"
        disk_size_gb      = "100"
      }
      os_profile {
        computer_name  = "hostname"
        admin_username = "testadmin"
        admin_password = "Password1234!"
      }
      os_profile_linux_config {
        disable_password_authentication = false
      }
      tags = {
        environment = "test-nonprod-provisioning"
      }
    }

Upvotes: 0

Views: 2428

Answers (1)

4c74356b41
4c74356b41

Reputation: 72211

valid options are:

  1. Attach
  2. Empty
  3. From Image

Empty doesnt make sense for OS disk

https://learn.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#diskcreateoptiontypes

Upvotes: 1

Related Questions