【发布时间】:2021-11-17 14:46:06
【问题描述】:
我在 tf 中有下一个任务:
resource "aws_eks_node_group" "managed_workers" {
for_each = var.nodegroups[terraform.workspace]
cluster_name = aws_eks_cluster.cluster.name
node_group_name = each.value.Name
node_role_arn = aws_iam_role.managed_workers.arn
subnet_ids = aws_subnet.private.*.id
tags = merge(
var.tags[terraform.workspace], {
"k8s.io/cluster-autoscaler/enabled" = "true"
"k8s.io/cluster-autoscaler/${var.cluster_name}" = "owned"
"type" = each.value.type
"Name" = each.value.Name
"ob" = each.value.ob
"platform" = each.value.platform
})
这个任务的输出是这样的:
{
"dev" = {
"ami_type" = "AL2_x86_64"
"arn" = "arn:aws:eks:eu-west-2:xxxxxxxxxxxxx"
"capacity_type" = "ON_DEMAND"
"cluster_name" = "EKS_Sps"
"disk_size" = 20
"force_update_version" = tobool(null)
"id" = "EKS_Sps"
"instance_types" = toset([
"m5a.large",
])
"labels" = tomap({
"autoscalergroup" = "pool"
"lifecycle" = "OnDemand"
})
"launch_template" = tolist([])
"node_group_name" = "EKS-Node-Name
"node_group_name_prefix" = ""
"node_role_arn" = "arn:aws:iam::xxxx:role/EKS_Sps-node"
"release_version" = "1.18.9-20210722"
"tags" = tomap({
"Name" = "EKS-nodegroup-name"
"environment" = "dev"
"k8s.io/cluster-autoscaler/EKS_Sps" = "owned"
"k8s.io/cluster-autoscaler/enabled" = "true"
"ob" = "all" <<<<----- I NEED THIS VARIABLE
"platform" = "api"
"type" = "EKS-TF-Sps"
})
}
现在我需要使用此资源任务的输出从像这样的新任务访问其他任务的“ob”值变量。类似于:each.value.tags(map).ob
非常感谢!
【问题讨论】:
-
抱歉,不清楚。你的变量是json字符串吗?究竟是什么,因为它是无效的TF格式。
-
这是特定资源任务的输出。我删除了一些部分以显示更清晰。我通过 terraform 控制台获取输出,所以它是 JSON。
-
所以你提供的输出是
each.value? -
不,each.value 是我需要在下面提供的输出中获得的示例。抱歉,如果不清楚:(
-
让我更新 OP。感谢您的帮助@Marcin
标签: amazon-web-services terraform amazon-eks