Description
What happened?
Unable to create immutable infrastructure with Pulumi when it comes to updating packer images as part of the storage profile due to the NIC being attached to the original virtual machine that we're attempting to update and replace.
Attempting to do so throws an error
Code="NicInUse" Message="Network Interface <NAMEOFNIC> is used by existing resource <RESOURCEUID>. In order to delete the network interface, it must be dissociated from the resource. To learn more, see aka.ms/deletenic." Details=[]
Expected Behavior
To be able to replace the virtual machine without deleting it first and causing downtime for users.
According to this stackoverflow https://stackoverflow.com/questions/39222278/terraform-and-updates this is possible in terraform although I am unable to test this myself.
With create_before_destroy set to true, Terraform will create the replacement server first, switch the IP to it, and then remove the old server. This allows you to do zero-downtime deployment with immutable infrastructure (note: zero-downtime deployment works better with a load balancer that can do health checks than a simple IP address, especially if your server takes a long time to boot).
Steps to reproduce
1 - Create a Network Interface Card
2 - Create a VM with the network interface card added under networkprofiles.networkInterfaces[0].id
3- Update the value of storageProfile.imageReference.id
4- Add replaceOnChanges: ["storageProfile.imageReference"]
to force a replacement (as this property doesnt seem to cause a replacement automatically)
Output of pulumi about
CLI
Version 3.78.1
Go Version go1.20.7
Go Compiler gc
Plugins
NAME VERSION
azure-native 2.3.0
command 0.8.1
nodejs unknown
tls 4.10.0
Host
OS ubuntu
Version 22.04
Arch x86_64
Dependencies:
NAME VERSION
@types/node 16.18.41
@pulumi/azure-native 2.3.0
@pulumi/command 0.8.1
@pulumi/pulumi 3.78.1
@pulumi/tls 4.10.0
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).