I started from a sam init
using Ruby 2.7. Run sam deploy --guided
and provide a phone number (you may get texted to confirm your subscription), latitude, and longitude. These are passed in to the weather.gov APIs, and this particular app focuses on wind. Of course, you can modify the handler logic to alarm on whatever you happen to care about (the APIs are public, easy to run curl
on them to explore what they return. If you are going to put this in a repo somewhere, you may also want to add samconfig.toml
to your .gitignore
so as to not broadcast your phone number, latitude, or longitude to the world.
In the future, I may enhance this to run on an hourly basis to collect "should notify" status overnight to be sent out in the morning, or to avoid re-texting the same adverse notification each hour on a high wind day. For that I might use something like AWS SSM (as a sort of cache of values like "when did I last send a text" or "has there been an adverse weather threshold since the last text notification" as key-value pairs) or AWS SQS (as an alternative, to send intent to notify into a queue each hour, and then a couple times a day flush the queue and send one or zero notifications).
This does not include all files, but it does have all files I modified from a hello world sam init
invocation.
Additionally, this doesn't really deal with alarming, and any errors will just be allowed to crash the Lambda. I don't have availability needs (given that this has only me as a customer), and a hard crash doesn't really cause any problems for the app overall. If you were to scale this out, you'd probably want alarming or soft-fails on errors.