小编szy*_*mon的帖子

如何忽略块中属性的更改

我正在 Azure 中部署 Web 应用程序,我想忽略对site_config块中scm_type属性的更改。

在部署期间,scm_type属性设置为None,稍后我们将在 Azure 门户中将其更改为不同的内容。

我当前的 TF 代码如下所示:

resource "azurerm_app_service" "web_app" {
  count               = length(var.app_names)
  name                = var.app_names[count.index]
  location            = data.azurerm_resource_group.app_resource_group.location
  resource_group_name = data.azurerm_resource_group.app_resource_group.name
  app_service_plan_id = azurerm_app_service_plan.app_plan.id
  tags                = var.tags
  app_settings        = var.app_settings[count.index]

  site_config {
    always_on                 = true
    websockets_enabled        = var.websockets_enabled[count.index]
    use_32_bit_worker_process = var.use_32_bit_worker_process
    scm_type                  = "None"
  }

  lifecycle {
    ignore_changes = [
      site_config.0.scm_type
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

我希望 terraform 计划在基础设施更新期间忽略scm_type 的变化,但它试图将其恢复为None。来自地形计划输出的行:

~ scm_type …

terraform terraform-provider-azure terraform0.12+

16
推荐指数
2
解决办法
2万
查看次数