Running a free Twitter bot on AWS Lambda

Victoria Drake

If you read About time, you’ll know that I’m a big believer in spending time now on building things that save time in the future. To this end I built a simple Twitter bot in Go that would occasionally post links to my articles and keep my account interesting even when I’m too busy to use it. The tweets help drive traffic to my sites, and I don’t have to lift a finger.

I ran the bot on an Amazon EC2 instance for about a month. My AWS usage has historically been pretty inexpensive (less than the price of a coffee in most of North America), so I was surprised when the little instance I was using racked up a bill 90% bigger than the month before. I don’t think AWS is expensive, to be clear, but still… I’m cheap. I want my Twitter bot, and I want it for less.

I’d been meaning to explore AWS Lambda, and figured this was a good opportunity. Unlike an EC2 instance that is constantly running (and charging you for it), Lambda charges you per request and according to the duration of time your function takes to run. There’s a free tier, too, and the first 1 million requests, plus a certain amount of compute time, are free. Roughly translated to running a Twitter bot that posts for you, say, twice a day, your monthly cost for using Lambda would total… carry the one… nothing. I’ve been running my Lambda function for a couple weeks now, completely free.

Read More