I have resource of type azurerm_virtual_machine_extension, I need to create this resource once, pass some parameters to it but never check on it again and create another resource of the same type which needs to be tracked for state. The reason why I have to do that is because Azure VM allows to use only once any type of VM extensions and I need to execute DSC type extensions, 2 times where first time as long as successfull does not need to be tracked anymore.
Well after fiddlind around with it for a day I found something which actually works. I documented it on blog but essentially it consists of first resource with lifecycle configured to ignore all changes, second resource which deletes first resource and then new resource being created with the same name as first one.
After my initial successful execution, I don’t need to track its state anymore. I need to create a second instance of the same VM extension type that must be tracked for state, as I intend to use DSC extensions again. The issue arises because Azure only allows each type of VM extension to be applied once per VM, which complicates my setup.