使用 DeployIfNotExists 策略对私有(private) dns 区域组进行 Azure Terraformignore_changes

标签 azure terraform azure-policy azure-private-dns-zone

我遇到了一个问题,Terraform 尝试更改由 DeployIfNotExists 策略部署的资源。此策略自动为专用端点 ( source ) 创建 DNS 条目。通常,我会使用 ignore_changes,但这仅适用于首先由 Terraform 部署的资源,然后忽略 Terraform 之外的所有 future 更改。

如何在没有 private_dns_zone_group 的情况下部署专用端点,以防止任何 future 的部署删除由 Azure 策略部署的 private_dns_zone_group

resource "azurerm_private_endpoint" "private_endpoint" {
  name                = var.private_endpoint_name
  location            = var.location
  resource_group_name = var.resource_group_name
  subnet_id           = var.private_subnet_id

  private_service_connection {
    name                           = var.private_service_connection_name
    is_manual_connection           = false
    private_connection_resource_id = azurerm_app_service.app_service.id
    subresource_names              = ["sites"]
  }

  # This cannot be included, otherwise the DeployIfNotExists policy will not run
  # private_dns_zone_group {
  #   name                 = "deployedByPolicy"
  #   private_dns_zone_ids = []
  # }

  lifecycle {
    ignore_changes = [
      private_dns_zone_group
    ]
  }
}

最佳答案

显然,问题来自内置的 Azure 策略。

您可以创建自定义策略,该策略将直接在Azure 私有(private) DNS 区域上创建记录。

关于使用 DeployIfNotExists 策略对私有(private) dns 区域组进行 Azure Terraformignore_changes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68225545/

相关文章:

Azure函数: "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information"

javascript - Azure 移动服务 : Custom Authentication using Java script backend?

c# - 无法在调试中创建 DataCacheFactory 实例

azure - 使用 Powershell 分配策略集(Azure Initiative)

json - 使用 Terraform 创建 Azure 策略

Azure应用服务架构理解: Per-App Scaling

Terraform 复杂变量定义

azure - Azure 上的 Terraform - 我正在尝试在一个资源中调用另一个资源中的 for_each block 的结果

amazon-web-services - 修改Terraform中自动生成的资源

Azure Policy 拒绝特定角色定义 ID(角色)的角色分配