Hi all. I wanted to ask you for some help.
I have a variable that looks like this:
variable "pol" {
default = {
"TOPIX" : {
"Top-prod CPUUtilization" : {
"query" : "SELECT average(`aws.rds.CPUUtilization`) FROM Metric WHERE aws.rds.DBInstanceIdentifier LIKE '%top-prod%'",
"critical_threshold" : 10,
"warning_threshold" : 5,
"operator" : "above"
},
"Top-prod ELB-4xx" : {
"query" : "SELECT sum(`aws.applicationelb.HTTPCode_ELB_4XX_Count`) FROM Metric WHERE aws.applicationelb.dnsName LIKE '%top-prod%'",
"critical_threshold" : 10,
"warning_threshold" : 5,
"operator" : "above"
}
},
"TOP2" : {
"Top2-prod CPUUtilization" : {
"query" : "SELECT average(`aws.rds.CPUUtilization`) FROM Metric WHERE aws.rds.DBInstanceIdentifier LIKE '%top-prod%'",
"critical_threshold" : 10,
"warning_threshold" : 5,
"operator" : "above"
},
"Top2-prod ELB-4xx" : {
"query" : "SELECT sum(`aws.applicationelb.HTTPCode_ELB_4XX_Count`) FROM Metric WHERE aws.applicationelb.dnsName LIKE '%top-prod%'",
"critical_threshold" : 10,
"warning_threshold" : 5,
"operator" : "above"
}
},
}
}
And I have a resource that should take those values.
policy_name = ""
alert_name = ""
critical_threshold = 0
operator = ""
query = ""
warning_threshold = 0
I want to create next resources:
---
policy_name = TOP
alert_name = "Top-prod CPUUtilization"
critical_threshold = 10
warning_threshold = 10
operator = "above"
query = string_from_the query_field
---
policy_name = TOP
alert_name = "Top-prod ELB-4xx"
critical_threshold = 10
warning_threshold = 10
operator = "above"
query = string_from_the query_field
---
policy_name = TOP2
alert_name = "Top2-prod ELB-4xx"
critical_threshold = 10
warning_threshold = 10
operator = "above"
query = string_from_the query_field
---
policy_name = TOP2
alert_name = "Top2-prod ELB-4xx"
critical_threshold = 10
warning_threshold = 10
operator = "above"
query = string_from_the query_field
There might be numerous policies or alerts.
How can I iterate over this type of map and get the correct values? Anybody?
Thanks in advance