2023-02-19

How do you specify an integration request with API gateway and Kinesis data streams in terraform?

I'm having trouble declaring an integration request resource in terraform that allows an API GateWay Method to push to a Kinesis data stream. I found this (See line 510) however I'm having a hard time understanding since it seems to specify which shard to post to and i thought this was done dynamically based on some id (eg. user_id). Any help?

resource "aws_api_gateway_integration" "post_method_integration" {
  rest_api_id             = aws_api_gateway_rest_api.my_api.id
  resource_id             = aws_api_gateway_resource.the_resource.id
  http_method             = aws_api_gateway_method.the_method.http_method
  integration_http_method = "POST"
  type                    = "AWS"
  uri = format(
    "arn:%s:apigateway:%s:kinesis:action/PutRecord",
    data.aws_partition.current.partition,
    var.default_region
  )
}

Edit: I solved it with

  uri = "arn:aws:apigateway:${var.default_region}:kinesis:action/PutRecord"
credentials = aws_iam_role.api_gw_kinesis_role.arn


No comments:

Post a Comment