Reputation: 443
I want to parameterise the request_parameters value in aws-api_gateway_method by using a file
So change:
resource "aws_api_gateway_method" "get" {
rest_api_id = var.api-id
resource_id = aws_api_gateway_resource.resource.id
http_method = "GET"
request_validator_id = aws_api_gateway_request_validator.validator.id
request_parameters = {
"method.request.querystring.Name" = true
}
}
into
resource "aws_api_gateway_method" "get" {
rest_api_id = var.api-id
resource_id = aws_api_gateway_resource.resource.id
http_method = "GET"
request_validator_id = aws_api_gateway_request_validator.validator.id
request_parameters = file(var.request-parameters-file)
}
I tried that with a .txt file but got an error as the value needs to be a map(bool). Fair enough, but how can I parameterise this field to enable me to use the resource within a module?
I have used a variable of type map(bool) and passed that in which is ok for simple cases but is going to get messy in more complex situations. Is there a better way ?
Upvotes: 1
Views: 1214
Reputation: 238209
You could represent your request_parameters
as json and then use jsondecode.
For example:
Have a file request_parameters.json
with content of:
{"method.request.querystring.Name": true }
Then in your aws_api_gateway_method
resource:
request_parameters = jsondecode(file("request_parameters.json"))
Upvotes: 2