Hello, here again I’m struggling with for_each
iteration.
Here what I actually want to achieve:
locals {
restapi = lookup(var.parameter, "resapi", [])
}
resource "aws_api_gateway_gateway_response" "rest" {
for_each = { for api, name in local.restapi : api => name }
rest_api_id = element([ for key, value in aws_api_gateway_rest_api.api : value.id ], each.key)
status_code = lookup(each.value.response, "code", null)
response_type = lookup(each.value.response, "type", null)
response_templates = lookup(each.value.response, "templates", null)
response_parameters = lookup(each.value.response, "options", null)
}
... Module `restapi`...
Other Code
parameters {
restapi = [
{
response = [
{
code = "400"
type = upper("Bad Request")
},
{
code = "401"
type = upper("Unauthorized")
},
{
code = "403"
type = upper("Forbidden")
}
]
}
]
}
Other Code
So now it only taking the first map:
{
code = "400"
type = upper("Bad Request")
},
Not iterating with others