【问题标题】:Terraform Error: Cycle: azurerm_subnet_service_endpoint_storage_policy.stgTerraform 错误:循环:azurerm_subnet_service_endpoint_storage_policy.stg
【发布时间】:2021-07-17 04:02:48
【问题描述】:

无法将 service_endpoint_policy_ids 附加到子网

service_endpoints 创建成功,但存储策略无法附加到子网

出现以下错误

Error: Cycle: azurerm_subnet_service_endpoint_storage_policy.stg, azurerm_subnet.backend, module.storage_bsai.var.vnet_subnet_id (expand), module.storage_bsai.azurerm_storage_account.storageaccount_name, module.storage_bsai.output.id (expand)

提供者 azurerm 版本 = "2.65.0"

用于存储策略和子网的 Terraform 资源

  resource "azurerm_subnet_service_endpoint_storage_policy" "stg" {
  name                = "storage-policy-bsai"
  resource_group_name = "${var.env}-bsai"
  location            = var.region
  definition {
    name        = "storage"
    #description = "definition1"
    service_resources = [
      module.resource_group.id,
      module.storage_bsai.id
    ]
  }
}
resource "azurerm_subnet" "backend" {
  depends_on           = [module.vnet]
  name                 = "backend"
  virtual_network_name = "${var.env}-${var.region}-bsai"
  resource_group_name  = "${var.env}-bsai"
  address_prefixes     = ["10.0.0.0/24"]
  service_endpoints = ["Microsoft.Storage", "Microsoft.AzureCosmosDB", "Microsoft.ServiceBus", "Microsoft.Web", "Microsoft.ContainerRegistry"]
  service_endpoint_policy_ids = [azurerm_subnet_service_endpoint_storage_policy.stg.id]
  delegation {
    name = "delegation"
    service_delegation {
      name    = "Microsoft.Web/serverFarms"
      actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
    }
  }
}

【问题讨论】:

    标签: azure terraform terraform-provider-azure


    【解决方案1】:

    service_endpoint_policy_ids 应该是一个列表:

    service_endpoint_policy_ids = [azurerm_subnet_service_endpoint_storage_policy.stg.id[
    

    【讨论】:

    • 即使列表也不起作用@Marcin
    【解决方案2】:

    发现问题 - 这似乎您的配置中有循环依赖? (即 2 个或更多资源相互依赖,这意味着 Terraform 无法协调需要以什么顺序发生的事情)

    https://github.com/terraform-providers/terraform-provider-azurerm/issues/12593#issuecomment-881192611
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-02
      • 1970-01-01
      • 2017-03-18
      • 1970-01-01
      相关资源
      最近更新 更多