Menu

A Lambda That Writes Back to the Bucket That Triggers It Can Bill You in a Loop. Here's a Safe Setup
📰

A Lambda That Writes Back to the Bucket That Triggers It Can Bill You in a Loop. Here's a Safe Setup

DEV Community: terraform·CloudSkill Consulting LLC·1 day ago
#Qbph4Z0U
#devtoterraform#devto#dev#bucket#incoming
Reading 0:00
15s threshold

As of October 29, 2026, this post sums up the official pages linked here.

The problem

A 2019 post on Reddit's r/aws describes a bill nobody wants. A team had a Lambda function that listened for new files in an S3 bucket. It read each file, changed it, and saved the result to S3. But the source bucket and the output bucket were set to the same bucket. So every saved result was a new file, and every new file started the function again.

It ran like that for about three and a half days, over a weekend, in a new account with no cost alerts yet. The bill was over $6,800, mostly for S3 PUT requests. The team only found out when someone at AWS asked them about the traffic.

This is a common trap. AWS even warns about it in the Lambda docs. In this post we explain the root cause, show a setup that can't loop, add guard rails in case someone breaks it later, and show how to test all of it.

Root cause: the output matches the trigger

An S3 trigger is a rule on the bucket.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.