Skip to content

API gateway HTTP integration with Kinesis Firehose

0

Hello, I am using API Gateway REST to track custom events from different e-commerce stores. The endpoint then posts the data to Kinesis firehose, which will batch the records to S3. Flow: API gateway -> Firehose -> S3

This does the work, but there is cost anomaly at API Gateway. Since i am using REST as the endpoint the price for number of requests is thrice as expensive as an HTTP API endpoint. All the features provided by REST (authentication, throttling etc.) is not required for me, i simply require an endpoint where i can post the events. So i am thinking to move from REST API to HTTP API , but HTTP API does not seem to support integration with Firehose (which is relatively cheap than kinesis data streams). It supports KDS, but that doesn't align with my requirement.

Can anyone help me with this :)

2 Answers
1

You're correct that HTTP API is generally more cost-effective than REST API for simple use cases like yours. However, you've identified a key limitation - HTTP API doesn't currently support direct integration with Kinesis Firehose.

Given your requirements, here are a few options you could consider:

  1. Keep using REST API with Firehose: If the cost difference isn't prohibitively high, this might still be the simplest solution, especially if it's already working well for you.

  2. Use HTTP API with Kinesis Data Streams (KDS): While this doesn't align perfectly with your current setup, it could be a viable alternative. You'd need to set up a process to move data from KDS to Firehose or directly to S3.

  3. Use HTTP API with a Lambda function: You could set up an HTTP API that triggers a Lambda function. The Lambda function would then write to Firehose. This adds a small amount of complexity but allows you to use the more cost-effective HTTP API while still leveraging Firehose.

  4. Direct client-to-Firehose: If possible, consider having your clients write directly to Firehose, bypassing API Gateway entirely. This would require careful management of credentials and permissions.

  5. Use Amazon EventBridge: You could set up an HTTP API endpoint that sends events to EventBridge, which can then be configured to send data to Firehose.

Each of these options has trade-offs in terms of cost, complexity, and scalability. The best choice depends on your specific requirements, expected traffic volume, and willingness to manage additional components in your architecture.

If cost is the primary concern and you don't need the additional features of REST API, option 3 (HTTP API with Lambda) might provide a good balance of cost-effectiveness and simplicity while allowing you to continue using Firehose.
Sources
HTTP API Gateway direct integration with Kinesis Data Stream | AWS re:Post
aws-apigateway-kinesisstreams - AWS Solutions Constructs
Ingest telemetry messages in near real time with Amazon API Gateway, Amazon Data Firehose, and Amazon Location Service | AWS Big Data Blog

answered a year ago

EXPERT

reviewed a year ago

0

Hey, great question, and yes, you're totally right: API Gateway REST APIs are significantly more expensive than HTTP APIs, especially at scale. If you don’t need features like usage plans, authorizers, or fine-grained throttling, HTTP APIs are a much better fit for your use case.

You're also right that HTTP APIs don’t support direct integration with Kinesis Firehose — they only support Kinesis Data Streams (KDS), which isn’t ideal for your S3 delivery model.

Workaround: Use HTTP API → Lambda Proxy → Firehose One popular, low-cost pattern is:

HTTP API → Lambda (minimal logic) → Firehose → S3

Here’s why this works well: HTTP API: Cheaper, simple, and still gives you a clean POST endpoint for tracking events. Lambda: Lightweight proxy (can be as short as 10–15 lines of code) that takes the request and pushes the payload to Firehose. Firehose: Continues to handle batching and delivery to S3 as usual.

This pattern is:

  Way cheaper than using REST API
  Still scales well, especially if the Lambda is short-lived and stateless.
  Gives you control to pre-process, enrich, or filter if needed later.

Example Python Lambda handler (just to show how light it can be):

import boto3 import json firehose = boto3.client('firehose') def lambda_handler(event, context): payload = event['body'] # Raw JSON string response = firehose.put_record( DeliveryStreamName='your-firehose-stream', Record={'Data': payload + '\n'} ) return { 'statusCode': 200, 'body': json.dumps({'message': 'Event received'}) }

Additionally, Use Lambda Function URLs if you want to bypass API Gateway entirely. https://docs.aws.amazon.com/lambda/latest/dg/urls-intro.html

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.