Terraform: 0.12.21
Provider: 2.0.0
azurerm_application_insights
No redeploy of Application Insights
Unexpected replacement of item:
~ application_type = "Web" -> "web" # forces replacement
Upgrade from 1.x to 2.0.0 with an azurerm_application_insights
item created with application_type = "Web"
from 1.x.
I think this is a intented change, see https://github.com/terraform-providers/terraform-provider-azurerm/commit/2bca57e3eaf85dfa95852f0a958759789a7b833e
That's pretty destructive. We now cannot upgrade to v2 of the provider without losing our production logs. We even tried amending the tfstate file but that didn't work either as there still appeared to be a copy of the old tfstate file in the tar file. Intended change it may be, but it seems to have unintended consequences that are leaving us scratching our heads.
After some experimentation we are no further forward because (perhaps not surprisingly) there seems to be no way to change the Application_Type
property in app insights once it's set, which I expect is why this becomes a destructive problem in TF. Although it's not clear because we are only using the default web
variety anyway, the case doesn't seem to cause Application Insights itself any problems and I cannot find any reference to that situation changing (I'm sure if it did then a lot of people would suddenly find their app insights instances not working which would be pretty bad for all concerned). With that in mind, would it not be possible to have TF make a case insensitive equality with the existing value so that anything created with v1 will not need to be recreated just for the sake of the casing on the value?
It is possible to make a workaround with lifecycle ignore_changes https://www.terraform.io/docs/configuration/resources.html#ignore_changes
Ah OK, I'll give that a go - might do what we want which would be great, cheers
Did exactly what we wanted, thank you. Didn't know about that resource behaviour customisation ability previously but it will be useful as I'm certain we have more instances of AI where the Application_Type
is improperly cased.
For anyone following on, here's a gist showing an example of this for application insights
Faced the same issue and the lifecycle ignore_changes helped. I think it would be good to add this information to https://www.terraform.io/docs/providers/azurerm/guides/2.0-upgrade-guide.html
This is still an issue that forces a workaround, when can we expect to have this resolved?
Most helpful comment
That's pretty destructive. We now cannot upgrade to v2 of the provider without losing our production logs. We even tried amending the tfstate file but that didn't work either as there still appeared to be a copy of the old tfstate file in the tar file. Intended change it may be, but it seems to have unintended consequences that are leaving us scratching our heads.