A bit of coding, a byte of the cloud. Learning to code a cheap and cheerful alerting tool in an AWS Lambda function.

Code can do it. You can code. Do it.

Years ago I learned on the job to write little PERL programs and Shell scripts to manipulate data in files submitted by clients who could not deliver their transaction data conformed to a record layout that my employer’s application could ingest. Did I lose you already? I chopped up some stuff to make it work. That’s what I love about code, it can do anything to anything for anything that needs doing with data.

At Tesloop, needs are much more realtime. When one of our vehicles arrives at a location where it is scheduled to pick up or drop off passengers, it’s that moment and the minutes that follow when the driver (pilot) or passenger may need help from the Operations team. Our developers created an SNS topic on AWS that our serverless application (using Kinesis Analytics) posts to when a vehicle enters a custom geofence that we have defined around each location. To give the team a heads up, a Slack post is best. Our driver mobile app also posts to Slack when arriving at locations, but redundancy is good and triggering based on the vehicle data creates some additional benefits. All we needed was a way to make a Slack post for each post to the SNS topic.

Inspired by a post on Medium by Joseph Terranova it seemed trivial to extend his code to extract a vehicle ID number from the data and construct a link to our fleet monitoring dashboard. I did this as a proof of concept, to be improved upon or completely re-architected by our developers later. The immediate goal was simply to alert the Ops team.

Below is the code you can copy-paste into your Lambda function after following Joseph’s instructions for creating your Slack webhook and SNS topic. Don’t forget to replace the values for:

  1. Slack webhook path (line 1)
  2. Slack channel (line 2)
  3. Slack posting username (line 3)
  4. Switch values (line 10-18)
  5. Message template (line 28)

The result for me was nice little notification posts like the one shown below. Done. Did it.

Slack say what?

Oh no, I broke my nerdboard. How DIY electronics skills and open source software saved the day, and my hands.

My hands were hurting. I work in software development, spending many hours each day typing, and I also play bass guitar in two bands (one coincidentally named Static Hands). The toll this took on my hands became so great that I was experiencing muscle spasms that immobilized my right thumb. Ouch.

At the greatly appreciated suggestion of a coworker, I looked at the Kinesis Advantage ergonomic keyboard. The reviews promised it would be like typing on clouds, but the price is steep at $350. I found one used for $150, a bargain, but this one had a defect. The tilde key was sticking, not the key cap as happens from a spilled soda, but inside the switch underneath. Uh oh.

DIY electronics skills to the rescue! I opened the keyboard and desoldered the offending key from the cool, curved circuit board that reminded of samurai armor.

The Kinesis Advantage “Nerdboard” comes with space for your favorite action figure.

Inside we see the curved circuit boards that the keys are soldered on to.

The desoldered key’s now empty circuit board contacts.

With the sticking key gone I still needed to re-map the tilde key, because I use the back tick character (which also lives on that key) for quoting code in Slack. An open source, free application called Karabiner did the job with ease, after a few puzzled minutes figuring out its quirky user interface.

Should you ever need key re-mapping, please support the creator of Karabiner with a $10 donation. Many open source software projects survive on donations alone, and they are worthy of our support. In the realm of audio, there is the venerable Audacity, which has saved me on more than one occasion when expensive audio editing applications broke down… but that’s for another post.