Closed janegilring closed 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 :)
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
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
Got it working! pushing new release 0.0.4
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.
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
Ah - removed -DependsOn $false and all good :)
Thanks for the tip regarding error action preference, will make sure to add it going forward.
Ok closing issue
Running this script generates the following Yaml code:
Applying this using pulumi up returns the following error
Module versions: