1

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 ?

1 Answer 1

2

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"))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.