Reputation: 41290
I recall seeing something like this in the documentation before, but I can't find it right now.
I have a list of instances I have created aws_instance.managers.*.id
what I want to do is convert it to another list suitable for cloudwatch dashboard which looks like
[
".",
"CPUCreditBalance",
".",
"i-0f2",
],
So say I have a list aws_instance.managers.*.id
which resolves to ["i-a", "i-b", "i-c"]
I want it to transform into something like
[
[
".",
"CPUCreditBalance",
".",
"i-a",
],
[
".",
"CPUCreditBalance",
".",
"i-b",
],
[
".",
"CPUCreditBalance",
".",
"i-c",
],
]
Presumably something like
locals {
dashboard_cpu_balance = [ foreach aws_instance.managers.*.id =>
[
".",
"CPUCreditBalance",
".",
"i-a",
],
]
}
Upvotes: 0
Views: 1598
Reputation: 588
something like this....
locals {
dashboard_cpu_balance = [ for a in aws_instance.managers.*.id :
[
".",
"CPUCreditBalance",
".",
a,
]
]
}
Output..
Outputs:
op = [
[
".",
"CPUCreditBalance",
".",
"i-a",
],
[
".",
"CPUCreditBalance",
".",
"i-b",
],
[
".",
"CPUCreditBalance",
".",
"i-c",
],
]
Upvotes: 2