Terraform grouping result
Link docs: https://developer.hashicorp.com/terraform/language/expressions/for#grouping-results
Code:
input: [
{
"name": "tcp-3306",
"location": "Test-02",
"protocol": "tcp",
"destination_ports": "3306",
"tags": "",
"group": "group01"
},
{
"name": "tcp-443",
"location": "Test-02",
"protocol": "tcp",
"destination_ports": "443",
"tags": "",
"group": "group02"
},
{
"name": "tcp-80",
"location": "Test-02",
"protocol": "tcp",
"destination_ports": "80",
"tags": "",
"group": "group01"
}
]
Output:
+ group = {
+ group01 = [
+ "TCP-3306",
+ "TCP-9001",
]
+ group02 = [
+ "TCP-9000",