English 中文(简体)
错误:在增加产出时没有证明属性
原标题:Error: Unsupported attribute when adding outputs

下述法典成功地在各地区的不同资源组群中部署了2×5个分析工作空间。

locals.tf

locals {
  resource_groups = {
    for k, v in var.workspaces : k => {
      location = v.location
    }
  }
}

main.tf

resource "azurerm_resource_group" "workspaces" {
  for_each = local.resource_groups

  name     = each.key
  location = each.value.location
}

resource "azurerm_log_analytics_workspace" "workspaces" {
  for_each = var.workspaces

  name                = each.key
  location            = each.value.location
  resource_group_name = azurerm_resource_group.workspaces[each.key].name
  sku                 = "PerGB2018"
  retention_in_days   = each.value.retention_in_days
}

variables.tf

variable "workspaces" {
  type = map(object({
    location          = string
    retention_in_days = number
  }))
  default = {
    workspace1 = {
      location          = "australiasoutheast"
      retention_in_days = 30
    }
    workspace2 = {
      location          = "australiaeast"
      retention_in_days = 30
    }
    # Add more workspaces as needed
  }
}

outputs.tf

# Define outputs
output "workspace_ids" {
  value = azurerm_log_analytics_workspace.workspaces[*].id
}

output "workspace_names" {
  value = azurerm_log_analytics_workspace.workspaces[*].name
}

output "resource_group_ids" {
  value = azurerm_resource_group.workspaces[*].id
}

output "resource_group_names" {
  value = azurerm_resource_group.workspaces[*].name
}

output "resource_group_locations" {
  value = azurerm_resource_group.workspaces[*].location
}

增加产出 我收到以下错误,无法确定原因。

最佳回答

由于您正在使用<条码>,因此,您必须使用<条码>值/代码>。 例如:

output "workspace_ids" {
  value = values(azurerm_log_analytics_workspace.workspaces)[*].id
}
问题回答

暂无回答




相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...

热门标签