Tuesday, 23 January 2018

Bots bots bots!

You may not know it, but I have written my fair share of bots.

(None of which are still operational, due to a combination of changing Twitter APIs and orphaned AWS accounts. So it goes)

About two days after I moved to the U.S., my friend Phil introduced me to a bunch of Neo-Maxi-Zoom-Dweebies who play a card game called Netrunner. After I joined their Slack chat and heard that the bot that was meant to respond to messages with pictures of card (similarly to the MTGCardFetcher in /r/MagicTCG), I took that opportunity to set up a Slackbot of my own.

But, for someone so used to CD, it was a hassle to keep reuploading .zips to S3 "by hand" every time I wanted to make changes. And I'd been itching for a change to learn CloudFormation. And, I figured, a general purpose "push button, generate Slackbot" might be something that a lot of people could have use for. So...I wrote it.

Running main.sh from that repo will bring you into an interactive wizard that sets up an AWS CodePipeline that polls for changes to a GitHub repo and publishes them to a Lambda function which is configured as a Slackbot. No part of it was particularly difficult (except figuring out how to model the actual updates! I wish there was a way to make CodePipeline just "update Lambda" as a stage, rather than having to make a full-on CloudFormation deployment), but cobbling it together took a fair bit of time.

As I call out there, it's far from "finished" - there are a ton of features I'd like to include, and I'm still not entirely clear on the best way to clean up stacks (it seems like you can't delete a stack if the role that created it no longer exists - but there's no warning if you delete a stack that contains the role that created another stack) - but something I want to work on more this year is finishing projects and actually talking about my work in public. So, this is me doing that!
(Also, it's really annoying that there's no way to interact with the Slack API commands from the command line. But even my uncle friend who works at Slack hasn't been able to find a way around that, so I guess it's not possible)

If you give it a try, please let me know! I'd love to hear your feedback or comments!

No comments:

Post a Comment