I’m getting a vector of arns of alarms from cloudwatch and I’d like to take those arns and put them on a map, each key having 10 arns. The key would be formed by ALARM_NAME_INDEX, with the index being a counter.
Alarm:
resource "aws_cloudwatch_metric_alarm" "test" {
count = length(data.aws_instances.test.ids)
alarm_name = "alarm_test_{data.aws_instances.test.ids[count.index]}"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "2"
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = "120"
statistic = "Average"
threshold = "80"
alarm_description = "This metric monitors ec2 cpu utilization"
insufficient_data_actions = []
dimensions = {
InstanceId = data.aws_instances.test.ids[count.index]
}
Currently, I’m putting all the arns in a vector in just one key of a map:
output "test1" {
value = tomap({
"Alarm" = aws_cloudwatch_metric_alarm.test.*.arn
)}
}
An example of what I want to do:
Ex: Supports having 35 arns of alarms in a vector to convert into a map
{Alarm_1, 10 arns},
{Alarm_2, 10 arns},
{Alarm_3, 5 arns}