Terraform "value of ' 计数'无法计算 : why?

标签 terraform

我的模板中有以下资源规范:

resource "azurerm_sql_firewall_rule" "allow_app_server" {
  count = "${length(split(",", azurerm_app_service.backend.outbound_ip_addresses))}"

  depends_on = ["azurerm_app_service.backend"]

  name                = "${format("Allow App Service Plan %d", count.index)}"
  start_ip_address    = "${element(split(",", azurerm_app_service.backend.possible_outbound_ip_addresses), count.index)}"
  end_ip_address      = "${element(split(",", azurerm_app_service.backend.possible_outbound_ip_addresses), count.index)}"
  resource_group_name = "${var.environment_resource_group_name}"
  server_name         = "${var.db_server_name}"
}

resource "azurerm_app_service" "backend" {
   # properties ommitted for brevity
}

现在当我运行时 terraform plan ,它与消息错误

azurerm_sql_firewall_rule.allow_app_server: value of 'count' cannot be computed



为什么?我能做些什么来解决这个问题(不需要我部分部署模板)?

最佳答案

你有双引号问题,试试这个:

count = "${length(split(',', azurerm_app_service.backend.outbound_ip_addresses))}"

关于Terraform "value of ' 计数'无法计算 : why?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54129495/

相关文章:

linux - 错误: host for provisioner cannot be empty

amazon-web-services - 如何访问元组的值?

amazon-web-services - 允许 CloudFront 使用源访问身份访问 S3 存储桶

使用 Terraform 托管虚拟网络中的 Azure 集成运行时

amazon-web-services - Github Actions 恢复/销毁 Terraform Plan 创建的 terraform AWS 基础设施

amazon-web-services - 找不到与 ID 为 vpc 的 vpc 匹配的子网

Terraform - 删除除一个以外的所有资源

amazon-web-services - 如何在iam策略terraform中编写条件?

amazon-web-services - Terraform 多个 s3 存储桶创建

google-cloud-platform - GCP Cloud Scheduler API 问题