Ignore changes of specific sticky settings

I’ve just added sticky_settings to my setup, and when running the plan it shows a couple of sticky settings that’s been automatically added by Azure, that are not visible in the portal eg. APPINSIGHTS_SNAPSHOTFEATURE_VERSION added by Application Insights

After adding the sticky_settings block, all the automatically added settings that’s currently sticky, but not defined in my code are shown as removed.

I’d like to ignore the changes of sticky settings made by eg. application insights, but I can’t figure out the syntax.

    ignore_changes = [
      sticky_settings[0].app_setting_names["APPINSIGHTS_SNAPSHOTFEATURE_VERSION"]
    ]

│ Error: Invalid index
│
│   on app-backend.tf line 82, in resource "azurerm_windows_web_app" "backend":
│   82:       sticky_settings[0].app_setting_names["APPINSIGHTS_SNAPSHOTFEATURE_VERSION"]
│
│ The given key does not identify an element in this collection value: a number is required.

I’m not sure if that means I need to reference the APPINSIGHTS_… by its index, and then how would I determine the index. Thought I might need to use [0] on app_setting_names as well.

    ignore_changes = [
      sticky_settings[0].app_setting_names[0].APPINSIGHTS_SNAPSHOTFEATURE_VERSION
    ]

│ Error: Unsupported attribute
│
│   on app-backend.tf line 82, in resource "azurerm_windows_web_app" "backend":
│   82:       sticky_settings[0].app_setting_names[0].APPINSIGHTS_SNAPSHOTFEATURE_VERSION
│
│ Can't access attributes on a primitive-typed value (string).

I also tried sticky_settings[0].app_setting_names[“APPINSIGHTS_SNAPSHOTFEATURE_VERSION”], and using [*]'s instead of [0]'s without any success.

Any ideas on how I might achieve this?
I’m on terraform 1.1.8 and azurerm 3.20.0

Hi @mrapan,

app_setting_names is a list of strings, so there is no further attributes which can be referenced. If you want to ignore the first item in the list, then you only need sticky_settings[0].app_setting_names[0]

Hi @jbardin,

thank you for the quick answer!
I’m worried there’s no guarantee what order these settings will be in, as they’re set by application insigths et al. and are not part of the tf config. Is there any other way to reference the sticky settings, preferably by name?

My alternative plan is to add the settings to our tf config to get control of the order, but I’m hesitant as they’re normally not set by users and not even visible in the portal.

I just noticed that if the settings that were added by app insights etc. are not defined in the tf config, they can not be ignored. So they have to be included in the tf config in order to ignore them.