0

I need to deploy guest extensions for linux based VMs that defined in script as

resource "azurerm_linux_virtual_machine" "vm-sample" {
  name = "vm-msample"
}

resource "azurerm_virtual_machine_extension" "vm-guests" {
   name                 = "${azurerm_linux_virtual_machine.vm-sample.name}/AzurePolicyforLinux"
   virtual_machine_id   = azurerm_linux_virtual_machine.vm-sample.id
   publisher            = "Microsoft.GuestConfiguration"
   type                 = "ConfigurationforLinux"
   type_handler_version = "1.0"
   settings = ""
 }

This definition I get from MSDN: https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/guest-configuration by adapt ARM template to .tf script

{
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "name": "[concat(parameters('VMName'), '/AzurePolicyforLinux')]",
  "apiVersion": "2019-07-01",
  "location": "[parameters('location')]",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', parameters('VMName'))]"
  ],
  "properties": {
    "publisher": "Microsoft.GuestConfiguration",
    "type": "ConfigurationforLinux",
    "typeHandlerVersion": "1.0"
    "autoUpgradeMinorVersion": true,
    "settings": {},
    "protectedSettings": {}
  }
}

But when I try to deploy it says the following:

Error: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="ResourceNotFound" Message="The Resource 'Microsoft.Compute/virtualMachines/vm-sample/extensions/vm-sample' under resource group 'rg-sample' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"

in CLI it works with result:

{
  "autoUpgradeMinorVersion": true,
  "enableAutomaticUpgrade": null,
  "forceUpdateTag": null,
  "id": "/subscriptions/<cut>/resourceGroups/rg-sample/providers/Microsoft.Compute/virtualMachines/vm-sample/extensions/AzurePolicyforLinux",
  "instanceView": null,
  "location": "eastus2",
  "name": "AzurePolicyforLinux",
  "protectedSettings": null,
  "provisioningState": "Succeeded",
  "publisher": "Microsoft.GuestConfiguration",
  "resourceGroup": "rg-sample",
  "settings": null,
  "tags": null,
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "typeHandlerVersion": "1.26",
  "typePropertiesType": "ConfigurationforLinux"
}

Please help me rewrite this ARM template to .tf script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.