title: How do I request azure spot instances using terraform, in a virtual machine scale set?
body: <p>Apologies in advance if I'm posing the question poorly, but I'd appreciate some help requesting spot instances in the context of a linux vmss.</p>
  <p>Here is the reference: <a href="https://www.terraform.io/docs/providers/azurerm/r/linux_virtual_machine_scale_set.html#identity" rel="nofollow noreferrer">https://www.terraform.io/docs/providers/azurerm/r/linux_virtual_machine_scale_set.html#identity</a></p>
  <p>and the relevant piece of it:</p>
  <p><a href="https://i.stack.imgur.com/M1ukJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M1ukJ.png" alt="enter image description here" /></a></p>
  <p>And here is their example json, without any indication of where the optional arguments go:</p>
  <pre><code>resource &quot;azurerm_linux_virtual_machine_scale_set&quot; &quot;example&quot; {
    name                = &quot;example-vmss&quot;
    resource_group_name = azurerm_resource_group.example.name
    location            = azurerm_resource_group.example.location
    sku                 = &quot;Standard_F2&quot;
    instances           = 1
    admin_username      = &quot;adminuser&quot;
  
    admin_ssh_key {
      username   = &quot;adminuser&quot;
      public_key = file(&quot;~/.ssh/id_rsa.pub&quot;)
    }
  
    source_image_reference {
      publisher = &quot;Canonical&quot;
      offer     = &quot;UbuntuServer&quot;
      sku       = &quot;16.04-LTS&quot;
      version   = &quot;latest&quot;
    }
  
    os_disk {
      storage_account_type = &quot;Standard_LRS&quot;
      caching              = &quot;ReadWrite&quot;
    }
  
    network_interface {
      name    = &quot;example&quot;
      primary = true
  
      ip_configuration {
        name      = &quot;internal&quot;
        primary   = true
        subnet_id = azurerm_subnet.internal.id
      }
    }
  }
  </code></pre>
  <p>I want to put the following two lines somewhere:</p>
  <pre><code>priority            = var.spot_priority
  eviction_policy     = var.spot_eviction_policy
  </code></pre>
  <p>but when I put them at the top level, I get this error:</p>
  <pre><code>Error: expected priority to be one of [Low Regular], got Spot
  </code></pre>
  <p>(obviously I've got it set to &quot;Spot&quot; in the <code>terraform.tfvars</code></p>
  <p>I've tried inserting them in various blocks, but they give me unexpected argument errors.</p>
  <p>Where do I tell terraform that I want spot instances??</p>
  <p>EDIT:  The problem is solved by passing in &quot;Low&quot; rather than &quot;Spot&quot; in the top level of the vmss resource.</p>