Thursday, July 7, 2016

List EC2 Instances in Hubot

I like slack.  I like automating things. I hate email.  Therefore, I like Hubot.  I've written Hubot scripts that integrate with our ticketing system (hal ticket #6515), launch Skype calls to everybody in the channel (hal skype).  Earlier this week, I added autoscaling notifications to Slack when our servers automatically scale up or down.  To go along with this, I wanted to see all the servers we're currently running in EC2.

I found some scripts that did roughly what I wanted,, but those scripts 1) Did more than I wanted and 2) didn't have the formatting I wanted for the ls command and 3) didn't filter in the way I wanted.  Based on yoheimuta's scripts I created a new npm package, hubot-ec2, that just lists instances.

Installation is straight forward in your hubot instance:

npm install --save hubot-ec2
npm install

After installing, set 3 environment variables


The keys used should be a user with the IAM Policy AmazonEC2ReadOnlyAccess.

Once thats all set, deploy your bot and you've got a new command, hubot ec2 ls.  You can filter by instance name hubot ec2 ls i-abcd1234 or by tag name hubot ec2 ls production-*.

It will look something like this when its all wired up:

Do you use hubot and slack?  What have you done to make it awesome?

No comments:

Post a Comment