In the Terraform documentation for AWS_API_GATEWAY_INTEGRATION, the following parameters are supported:
- rest_api_id
- resource_id
- http_method
- type
- uri
- integration_http_method
They give this example:
resource "aws_api_gateway_integration" "MyDemoIntegration" {
rest_api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}"
resource_id = "${aws_api_gateway_resource.MyDemoResource.id}"
http_method = "${aws_api_gateway_method.MyDemoMethod.http_method}"
type = "MOCK"
}
But I would like to specify a mapping template (as well as a Lambda integration), as you can with the UI:
However I see no way of doing that with Terraform. Is is possible ?
Note: What I am currently doing is apply
ing the rest of the configuration (lambda, s3, iam etc...), and then adding mapping template manually afterwards (as well as the integration type of lambda).
But then every time I terraform apply
to apply some other config (eg: s3), Terraform reverts back the mapping template and the integration type.
The "reverting" plan looks like this:
~ aws_api_gateway_integration.post_hit_integration
request_templates.#: "1" => "0"
request_templates.application/json: "{\n \"body\" : $input.json('$'),\n \"headers\": {\n #foreach($param in $input.params().header.keySet())\n \"$param\": \"$util.escapeJavaScript($input.params().header.get($param))\" #if($foreach.hasNext),#end\n \n #end \n },\n \"stage\" : \"$context.stage\"\n}" => ""
uri: "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:000000000000:function:create_hit/invocations" => ""