Skip to content
Automatically delete your old Tweets with AWS Lambda
Go Shell
Branch: master
Clone or download
Pull request Compare This branch is 25 commits ahead, 1 commit behind adamdrake:master.
victoriadrake Merge pull request #4 from billglover/fix/error-handling
Log error returned by getTimeline()
Latest commit b226e6a Jul 30, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Make function return json response Jan 7, 2019 Update README Jul 25, 2019
main.go Merge pull request #4 from billglover/fix/error-handling Jul 31, 2019 Make function return json response Jan 7, 2019

ephemeral: automatically delete your old Tweets with AWS Lambda

ephemeral is a Twitter timeline grooming program that runs for pretty much free on AWS Lambda. The code is forked from Adam Drake's excellent Harold butler-like bot and refactored for Lambda.

You can use ephemeral to automatically delete all tweets from your timeline that are older than a certain number of hours that you can choose. For instance, you can ensure that your tweets are deleted after one week (168h), or one day (24h).

The program will run once for each execution based on the trigger/schedule you set in AWS Lambda. It will delete up to 200 expired tweets (per-request limit set by Twitter's API) each run.

Twitter API

You will need to create a new Twitter application and generate API keys. The program assumes the following environment variables are set:


MAX_TWEET_AGE expects a value of hours, such as: MAX_TWEET_AGE = 72h

Optionally, you can whitelist certain tweets and save them from deletion by setting the variable WHITELIST with the tweet's ID as the value. Find the ID as the string of numbers at the end of the tweet's URL, for example: 1052624100617785344

Set one ID to whitelist, or multiple IDs using the separator : like so:

WHITELIST = 1052624100617785344:1052942396034609152

You can set these variables in AWS Lambda when you create your Lambda function. For a full walkthrough with screenshots on creating a Lambda function and uploading the code, read this blog post. Skip to setting environment variables at this link.

This handy bash script is included to help you upload your function code to Lambda. It requires AWS Command Line Interface. To set up, do pip install awscli and follow these instructions for Quick Configuration.


Copyright (C) 2018-2019 Victoria Drake

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see

You can’t perform that action at this time.