worxspace / PSPulumi

GNU General Public License v3.0
7 stars 1 forks source link

Invalid parameter 'requireGuestProvisionSignal' when trying to provision an Azure VM #8

Closed janegilring closed 2 years ago

janegilring commented 2 years ago

Running this script generates the following Yaml code:

{
  "resources": {
    "nic": {
      "options": {
        "dependson": [
          "False"
        ]
      },
      "type": "azure-native:network:NetworkInterface",
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "subnet": {
              "id": "/subscriptions/380d994a-e9b5-4648-ab8b-815e2ef18a2b/resourceGroups/networking-rg/providers/Microsoft.Network/virtualNetworks/norway-vnet/subnets/vm-subnet"
            }
          }
        ],
        "resourceGroupName": "${testrg.name}",
        "networkInterfaceName": "jandemovm01-nic"
      }
    },
    "testrg": {
      "options": {
        "dependson": [
          "False"
        ]
      },
      "type": "azure-native:resources:ResourceGroup",
      "properties": {
        "resourceGroupName": "test-rg"
      }
    },
    "sa": {
      "options": {
        "dependson": [
          "False"
        ]
      },
      "type": "azure-native:storage:StorageAccount",
      "properties": {
        "location": "norwayeast",
        "accountName": "pspulumitest",
        "resourceGroupName": "${testrg.name}",
        "kind": "StorageV2",
        "sku": {
          "name": "Standard_LRS"
        }
      }
    },
    "vm": {
      "options": {
        "dependson": [
          "False"
        ]
      },
      "type": "azure-native:compute:VirtualMachine",
      "properties": {
        "storageProfile": {
          "dataDisks": null,
          "imageReference": {
            "sku": "20_04-lts-gen2",
            "publisher": "canonical",
            "version": "latest",
            "offer": "0001-com-ubuntu-server-focal",
            "id": null
          },
          "osDisk": {
            "vhd": null,
            "name": "jandemovm01OsDisk",
            "managedDisk": {
              "storageAccountType": "Standard_LRS",
              "diskEncryptionSet": null,
              "id": null
            },
            "osType": null,
            "createOption": "FromImage",
            "caching": "ReadWrite",
            "encryptionSettings": null,
            "diskSizeGB": 30,
            "writeAcceleratorEnabled": false,
            "deleteOption": null,
            "diffDiskSettings": null,
            "image": null
          }
        },
        "hardwareProfile": {
          "vmSize": "Standard_D2s_v4"
        },
        "osProfile": {
          "requireGuestProvisionSignal": false,
          "secrets": null,
          "computerName": "jandemovm01",
          "adminPassword": "!SuperSecret12345!",
          "adminUsername": "jandemoadmin",
          "customData": null,
          "linuxConfiguration": null,
          "windowsConfiguration": null,
          "allowExtensionOperations": false
        },
        "vmName": "jandemovm01",
        "resourceGroupName": "${testrg.name}",
        "networkProfile": {
          "networkInterfaces": [
            {
              "deleteOption": null,
              "id": "${nic.id}",
              "primary": true
            }
          ],
          "networkInterfaceConfigurations": null,
          "networkApiVersion": null
        }
      }
    }
  },
  "variables": {},
  "outputs": {}
}

Applying this using pulumi up returns the following error

azure-native:compute:VirtualMachine (vm):
    error: Code="InvalidParameter" Message="The property 'requireGuestProvisionSignal' is not valid because the 'Microsoft.Compute/Agentless' feature is not enabled for this subscription." Target="requireGuestProvisionSignal"

Module versions:

Get-Module psp* | ft name,version

Name                               Version
----                               -------
pspulumiyaml                       0.0.2
pspulumiyaml.azurenative.compute   0.0.3
pspulumiyaml.azurenative.network   0.0.3
pspulumiyaml.azurenative.resources 0.0.3
pspulumiyaml.azurenative.storage   0.0.3
rdbartram commented 2 years ago

i am looking into this and will add you gist as an additional example in this project...so i will make sure it works before i push again :)

rdbartram commented 2 years ago

also i wont include it in my example but you can use this...for your case with the existing subnet

doc https://www.pulumi.com/registry/packages/azure-native/api-docs/network/getsubnet/

$subnet = Invoke-AzureNativeFunctionNetworkGetSubnet -resourceGroupName $testrg.reference("name") -subnetName "vm-subnet" -virtualNetworkName "norway-vnet"

$NicProperties = @{
    resourceGroupName    = $testrg.reference("name")
    networkInterfaceName = "jandemovm01-nic"
    pulumiid             = "nic"
    ipConfigurations     = @(
        [pscustomobject]@{
            name            = "ipconfig1"
            subnet          = $subnet.reference("id")
            #publicIPAddress = @{id = $null}
        }
    )
}

$VmNic = New-AzureNativeNetworkNetworkInterface @NicProperties
rdbartram commented 2 years ago

oh man...so i found this in the api docs

Note: This property is for private testing only, and all customers must not set the property to false.

and because you aren't settings it...it defaults to false...so i need to see if i can handle this in dynamic generation

rdbartram commented 2 years ago

Got it working! pushing new release 0.0.4

janegilring commented 2 years ago

Nice!

I went ahead and updated the modules and invoke pulumi, but for some reason it wanted to delete all resources:

PS /workspaces/pspulumidemo> pulumi up -s jantest
Previewing update (jantest)

View Live: https://app.pulumi.com/janegilring/psyamlpulumi/jantest/previews/53586c49-8a63-4833-96b7-9468d80a0724

     Type                                      Name                  Plan       
     pulumi:pulumi:Stack                       psyamlpulumi-jantest             
 -   ├─ azure-native:network:NetworkInterface  nic                   delete     
 -   ├─ azure-native:storage:StorageAccount    sa                    delete     
 -   └─ azure-native:resources:ResourceGroup   testrg                delete     

Resources:
    - 3 to delete
    1 unchanged

I went ahead anyway, and on the next run it finds no changes and don`t want to provision any resources.

Could it be a regression?

By the way, do you think what-if against ARM would detect any of the issues seen so far? Wondering if some integration tests based on that would make sense.

rdbartram commented 2 years ago

Ok, so I assume you didn’t change your code. So there is a couple things. Do as I do in my example pulumi.yaml and include the erroractionpreference =“stop” you can also do this at the top of your powershell.ps1.

I did introduce one breaking change to the code base by renaming dependson to pulumidependson. This was to avoid conflicts with resource params.

adding that too but will make sure errors surface in pulumi and not just destroy resources.

btw if pulumi wanted to redeploy something it would show as replace in the state and not delete and then on another run redeploy :)

have fun

janegilring commented 2 years ago

Ah - removed -DependsOn $false and all good :)

Thanks for the tip regarding error action preference, will make sure to add it going forward.

rdbartram commented 2 years ago

Ok closing issue