Lifecycle issue

Hello, Please suggest how to fix this issue.
My Code:
lifecycle {
prevent_destroy = var.instance_name[count.index] == backend ? true : false
}

Getting error like below:

Error: Variables not allowed

│ on azurevm.tf line 45, in resource “azurerm_virtual_machine” “main”:
│ 45: prevent_destroy = var.instance_name[count.index] == backend ? true : false

│ Variables may not be used here.


│ Error: Unsuitable value type

│ on azurevm.tf line 45, in resource “azurerm_virtual_machine” “main”:
│ 45: prevent_destroy = var.instance_name[count.index] == backend ? true : false

│ Unsuitable value: value must be known


│ Error: Variables not allowed

│ on azurevm.tf line 45, in resource “azurerm_virtual_machine” “main”:
│ 45: prevent_destroy = var.instance_name[count.index] == backend ? true : false

│ Variables may not be used here.


│ Error: Variables not allowed

│ on azurevm.tf line 45, in resource “azurerm_virtual_machine” “main”:
│ 45: prevent_destroy = var.instance_name[count.index] == backend ? true : false

│ Variables may not be used here.

Terraform is telling you that it does not allow prevent_destroy to contain variables. It just doesn’t support it.