Weekly AWS Lambda storage cleanup with a Slack summary

Every Sunday night, clear out the old Lambda versions quietly filling your storage quota, log every deletion, and post the numbers to Slack.

Agentic Task
AWS LambdaGoogle SheetsSlack BotEngineeringOperationsNotifications & AlertsResearch & Monitoring
PromptCreate

Every Sunday at 10pm, audit my AWS Lambda code storage and prune the old published function versions that are quietly eating my 75GB per-region account quota.

Start with the AWS Lambda Get Account Settings operation to read my current code storage usage against the account code size limit for the region. Work out what percentage of the limit is in use, and hold on to that starting number for the summary at the end.

If usage sits below 60 percent of the limit, skip the deletions entirely. Post a single status line to Slack with the current usage and remaining headroom, then finish. This workflow should stay quiet until storage actually matters. Treat the 60 percent threshold as a setting I can change.

When usage is at or above that threshold, use List Functions to enumerate every function in the region. These list endpoints paginate with Marker and NextMarker, so page all the way through rather than reading only the first page. For each function, call List Versions By Function to get its published versions and List Aliases to see which versions are currently referenced.

Decide what is safe to delete using three hard rules that must never be broken: never touch $LATEST, never delete a version that any alias points to (including both the alias target and any versions named in an alias routing configuration), and always keep the three most recent published versions of every function. Treat the keep count of three as a setting I can change. Anything that fails any of these checks stays.

Delete what remains with Delete Function, passing the version as the qualifier so only that single version is removed and never the whole function. When a function name or ARN contains a colon, URL-encode it as %3A in the path. Record the code size of each version before deleting it so I know exactly how much was reclaimed.

Log every single deletion as a row in Google Sheets using Append Values, with the date, the function name, the version number, and the size reclaimed. These deletions are irreversible, so this log is my permanent audit trail. Write the rows as you go rather than batching them at the very end.

Once the pass is complete, call Get Account Settings again to read the storage figure after cleanup, then post a summary to Slack with Send a Message. Include storage used before and after, total GB reclaimed, the number of versions removed per function, and how much quota headroom is left. If nothing qualified for deletion, say so plainly instead of sending an empty report.

What does this prompt do?

  • Checks how much of your AWS Lambda storage allowance is already used, and stays quiet when there is plenty of room left
  • Finds old function versions that are safe to retire, always keeping the three newest and anything a live alias like prod or staging points at
  • Records every removal in a Google Sheet with the date, function, version and space recovered, so you have a permanent trail
  • Posts a Slack summary showing storage before and after, total space recovered, and how much headroom you have left

What do I need to use this?

  • An AWS account with Lambda functions, plus access keys for the region you want cleaned up
  • A Google account and a spreadsheet to hold the cleanup log
  • A Slack workspace and a channel for the weekly summary

How can I customize it?

  • Change how many recent versions to keep for each function (three by default)
  • Move the quiet threshold up or down, so nothing is deleted until usage passes the level you set
  • Pick a different day and time, a different Slack channel, or a different logging spreadsheet

FAQs

Can this delete something my production traffic depends on?
No. It never touches the live working copy of a function, never removes a version that an alias such as prod or staging points to, and always leaves the three most recent published versions in place. Anything that fails one of those checks is skipped.
What happens if my storage is nowhere near full?
Nothing gets deleted. If usage is under 60 percent of your allowance, the workflow just posts a short status line to Slack so it stays quiet until it actually matters. You can move that threshold to whatever level suits you.
Why does Lambda storage fill up in the first place?
Every time you deploy an update to an existing function, the previous published version is kept. Over months of deploys those old copies add up, and once you reach the limit new deployments simply stop working.
Can I undo a deletion?
No, removing a version is permanent. That is exactly why every deletion is written to a Google Sheet with the date, function name, version number and size before the summary goes out, so you always have a record of what was removed and when.
Does it cover all of my functions at once?
Yes. It works through every function in the region your credentials point at, including accounts with hundreds of functions, and reports how many versions were removed for each one.

Related templates

Prospecting desk that builds account lists from the live web

Stop buying stale lists. Reps run a saved search, work the results like an inbox, and only the accounts they approve ever reach your CRM.

Hyperbrowser
HubSpot
Google Sheets
App
Share of voice dashboard for your brand and competitors

See how your brand's news coverage and sentiment stack up against four competitors, then let an assistant write the weekly report for you.

GDELT
Notion
Slack Bot
App
Approval war room for every social post awaiting sign-off

One screen showing every social post waiting on approval, sorted by deadline, so reviewers can approve or reject without leaving the page.

Hootsuite
Slack Bot
App
Turn champion job changes into new pipeline in Attio

Every Monday, find the past champions and closed-won contacts who changed jobs, update Attio, and get the moves worth chasing in Slack.

Boomerang
Attio
Slack Bot
Agentic Task
Collect social post requests and schedule them in Hootsuite

Staff submit what happened, your social manager edits the copy, picks the accounts and puts it on the calendar without a single spreadsheet.

Hootsuite
Slack Bot
General Input Database
App
Influencer campaign roster board with AI creator briefs

Drag creators through Sourced to Wrapped on a board grouped by campaign, with audience stats on every card and a one-click brief for each creator.

HypeAuditor
Google Sheets
Notion
App

Stop letting old Lambda versions break your deploys.

Set this up once and your storage quota looks after itself every Sunday night, with a full record of everything that was removed.