add mapping template for API in Terraform

Viewed 380

I want to add a header (Content-Type) and a mapping template within the integration request of my AWS API Gateway. While following this tutorial, I could easily add those parameters via the console. https://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-kinesis.html

However, I am unable to figure out the syntax to add them using Terraform. This is my integration request so far:

resource "aws_api_gateway_integration" "kinesis_integration" {
  rest_api_id          = aws_api_gateway_rest_api.shippeo_api_kinesis.id
  resource_id          = aws_api_gateway_resource.shippeo_api_resource_kinesis.id
  http_method          = aws_api_gateway_method.post_json_files_kinesis.http_method
  credentials          = aws_iam_role.shippeo_integration_role.arn
  type                 = "AWS"
  uri                  = "arn:aws:apigateway:eu-central-1:kinesis:action/PutRecord"
  integration_http_method     = "POST"
  depends_on = [
    aws_api_gateway_resource.shippeo_api_resource_kinesis
  ]
}

How can I specify the header (Content-Type)+Mapped From and the mapping templates as shown below using Terraform?

enter image description here Mapping Template:

{
    "StreamName": "$input.params('stream-name')",
    "Data": "$util.base64Encode($input.json('$.Data'))",
    "PartitionKey": "$input.path('$.PartitionKey')"
}

In the documentation, selection_pattern and response_templates is mentioned but I am not sure how to use it in my case.

0 Answers
Related