Serverless · Freelance

IoT Data Ingestion on EKS with Helm and Lambda Video Transcoding Pipelines

A device ingestion path from AWS IoT Core into services on EKS deployed with Helm, plus event-driven Lambda and Docker video transcoding and timelapse generation.

  • AWS IoT Core
  • Amazon EKS
  • Helm
  • AWS Lambda
  • Docker
  • FFmpeg
  • Amazon S3
  • Terraform

// Why this matters

An aws iot core to eks pipeline solves a specific split: devices need a managed, secure front door that can hold millions of connections, while your business logic needs the flexibility of a normal container platform. IoT Core is very good at the first and not meant for the second, and EKS is the opposite.

Media is a separate problem that often arrives with the same project. Cameras and apps upload large video files in whatever format they produce, and users want streamable renditions and timelapses. Doing that on always-on servers wastes money between uploads.

I built both sides: a device ingestion architecture deployed on EKS with Helm, and event-driven transcoding and timelapse tooling using Lambda and Docker. They share a design principle: managed services at the edges, your code only where it adds value.

// The problem

Device fleets break naive designs. Thousands of devices behind an HTTP API means managing TLS, authentication, keep-alives and reconnect storms yourself. A single shared credential means one leaked device compromises the fleet, and rotating it means touching every device.

The consumer side has the opposite shape. Ingestion services have state and dependencies (databases, caches, object stores) and need rolling updates, configuration per environment and health checks. Copy-pasted manifests per environment diverge and make rollbacks guesswork.

Video processing adds a compute-heavy, spiky workload. Transcoding on a long-running server leaves it idle most of the day, and one large upload can starve everything else. Lambda's runtime and package limits push people to give up on it, though a container image removes most of those limits.

// The solution

On the device side, each device gets its own certificate and an IoT policy that allows connecting with its own client ID and publishing only to its own topic prefix. Policy variables such as the thing name make one policy document serve the whole fleet. Devices publish MQTT to a topic like telemetry/<device-id>.

An IoT rule with a SQL-like statement selects the messages and forwards them to a target. For an EKS consumer, the practical options are routing into a stream or queue the service reads, or to an HTTPS endpoint behind a load balancer. I prefer the queue or stream because it buffers bursts and decouples release cadence from device traffic.

The ingestion workloads on EKS are packaged as a Helm chart: a deployment for the consumer, a service, a horizontal pod autoscaler and config. Each environment is one values file. Rolling updates with readiness probes mean a bad build never takes traffic, and helm rollback is the recovery path.

For video, an S3 event on the input bucket invokes a Lambda built from a container image that includes FFmpeg. The function downloads the object to its temporary storage, runs FFmpeg to produce the renditions, and uploads the results to an output bucket. Container images allow up to ten gigabytes and ephemeral storage can be raised, which covers most clip lengths. Long or very large jobs should move to a container service instead.

Timelapses are the same machinery on a schedule: collect the day's frames from a prefix, sort them, and ask FFmpeg to assemble them at a chosen frame rate. Alternatives I weighed: MediaConvert for broadcast-grade formats (excellent, but heavier than needed for simple renditions), and running FFmpeg on EKS jobs (more control, more cluster to manage). A managed ladder is described in Serverless Video-on-Demand with MediaConvert, CloudFront and Cognito, and a container Lambda for audio is in Container-Image Lambdas for Audio Segmentation and Sentiment.

How it flows flow1. Device publishes → 2. Authenticate → 3. Rule → 4. Ingest → 5. Store → 6. Upload media → 7. Transcode → 8. Output01Device publishes02 · GATEAuthenticate03Rule04Ingest05Store06Upload media07Transcode08Output
How it flows. End-to-end flow. Dashed pink nodes are gates: points where a human or a check must pass before the next stage runs.
  1. Device publishesMQTT message to a topic scoped to the device
  2. Authenticate gateX.509 certificate and IoT policy checked by IoT Core
  3. RuleIoT rule selects and forwards matching messages
  4. Ingestrule target feeds the ingestion service on EKS
  5. Storeservice writes to the database and object storage
  6. Upload mediacamera or app places video in S3
  7. TranscodeS3 event invokes a container Lambda running FFmpeg
  8. Outputrenditions and timelapse land in an output bucket
DeviceIoT CoreQueueEKS serviceDatabaseconnect with certificatepublish telemetry/<id>rule forwards messagepoll and receivewrite recorddelete message
Device message to stored record. Authentication happens at the edge; processing is decoupled by a queue.
EdgeIoT CoreS3 input bucketPer-device policiesRoutingIoT rulesS3 eventsQueueComputeEKS ingestion podsFFmpeg container LambdaTimelapse jobStorageDatabaseOutput bucketContainer registry
Two pipelines, one platform. Device ingestion and media processing share storage and observability.

// Before you start

  • An AWS account with permissions for IoT Core, EKS, Lambda, ECR and S3
  • kubectl, Helm 3.12 or later, AWS CLI v2 and Docker installed
  • An existing EKS cluster and a configured kubeconfig context
  • A test device or an MQTT client that can use X.509 certificates
  • Familiarity with MQTT topics and basic FFmpeg usage

// Step-by-step implementation

  1. 01 Create a thing, certificate and a topic-scoped policy

    Register each device as a thing, create a certificate and attach a policy that uses the thing name variable. The policy lets a device connect only as itself and publish only under its own topic. That is the control that limits a compromised device to its own data.

    Store the private key on the device only. Never commit it or paste it anywhere.

  2. 02 Route telemetry with an IoT rule

    A rule selects fields from the topic and sends them to a target. Using the topic function you can extract the device ID into the payload, so downstream code does not parse topics. The target here is an SQS queue that the cluster service reads.

    The rule needs an IAM role that allows sending to the queue.

  3. 03 Package the EKS workloads as a Helm chart

    The consumer is a deployment that polls the queue, with an autoscaler on CPU. Put image, replica bounds and the queue name into values, so environments differ only by file.

    Give the service account an IAM role through IRSA so pods read the queue without static keys.

  4. 04 Deploy and roll back with Helm

    Install with the environment values file and the atomic flag, which rolls back automatically if readiness never succeeds. Keep a values file per environment in version control and promote by changing the image tag.

    history and rollback are your safety net when a release misbehaves.

  5. 05 Build the FFmpeg container image for Lambda

    Start from the Lambda Python base image, add a static FFmpeg binary and your handler. A container image avoids the zip size limit and keeps the dependency set reproducible. Set the entry point to the handler function.

    Pin the FFmpeg build so renditions stay consistent between deploys.

  6. 06 Write the transcode handler triggered by S3

    The function reads the bucket and key from the S3 event, downloads to /tmp, runs FFmpeg for each target size, and uploads the results. Use the key's base name to build output keys, and avoid writing to the input bucket or you create a loop.

    Raise the function memory and ephemeral storage to match the largest clip you expect.

  7. 07 Deploy the function and connect the S3 trigger

    Push the image to ECR, create the function from it, then add the bucket notification. Grant S3 permission to invoke the function before creating the notification, or the call is rejected.

    Filter the notification by a suffix so only video files trigger work.

  8. 08 Assemble a timelapse from frames

    A timelapse is a single FFmpeg command over an ordered set of images. Sync the day's frames to local storage, sort by name (timestamped names sort correctly), and encode at a modest frame rate. Run this from a scheduled Lambda or a Kubernetes CronJob for longer jobs.

    Use a glob pattern input and set pixel format explicitly for broad player compatibility.

// How to verify it works

  • Publishing a test message from a device or MQTT client appears in the telemetry queue within seconds.
  • A client using another device certificate cannot publish to a different device topic (connection or publish is denied).
  • kubectl get pods shows the ingest pods Ready, and the queue depth falls to zero under load.
  • Uploading a sample video to the input bucket creates 720p and 480p files in the output bucket.
  • The timelapse file plays and its duration equals frame count divided by frame rate.

// Design decisions and trade-offs

  • Let IoT Core terminate device connections and route messages with rules
  • Run the stateful consumers on EKS, deployed as a Helm release per environment
  • Use per-device certificates and policies scoped to the device topic
  • Trigger transcoding from S3 events and run FFmpeg in a container Lambda
  • Generate timelapses by batching frames on a schedule rather than streaming them

// Pitfalls and lessons learned

  • A shared certificate for all devices removes any ability to revoke one device; issue one per device.
  • Policies that grant publish on a wildcard topic let one device impersonate another.
  • Writing Lambda outputs back into the trigger bucket causes an invocation loop and a large bill. Use a separate output bucket.
  • Default Lambda ephemeral storage is only 512 MB and silently truncates big transcodes; raise it explicitly.
  • S3 object keys in events are URL encoded; decode them or keys with spaces fail to download.
  • Helm upgrades without --atomic leave half-rolled releases when probes fail.

// Frequently asked questions

How do I send IoT Core data to EKS?

Use an IoT rule to forward messages to a queue or stream that a service on EKS reads, which buffers bursts and decouples releases.

Can Lambda run FFmpeg?

Yes. Package a static FFmpeg binary in a container image and trigger the function from S3 events; mind memory, timeout and ephemeral storage.

Why Helm for EKS workloads?

It gives versioned, repeatable releases with a values file per environment and an easy rollback.

How do I secure IoT devices?

Issue per-device certificates and attach policies scoped to that device client ID and topic prefix.

How do I make a timelapse from images?

Run FFmpeg over the ordered frames with a chosen frame rate and yuv420p pixel format.

// The outcome

Devices connect securely without any server for connection handling, ingestion services scale on the cluster, and media files are transcoded automatically on upload with no idle capacity to pay for.

// Where to take it next

// Keep reading