Neat trick: Use AWS SNS to get a text message when a process completes
As software developers we sometimes end up doing really long-winded things such as migrating databases or re-compiling large projects. We often ‘fire-and-forget’, going off to do some other task while our process finishes.
Typically, we then repeatedly interrupt ourselves to check back on the task, or just completely forget about it until long after it’s complete.
Some enterprising developers use sendmail
to send themselves an email when their process completes. It looks something like:
But sendmail
requires some non-trivial configuration to get working, and you may only be getting emails on the machine you’re working on anyway. Wouldn’t it be nice to get a reminder on your phone?
With AWS SNS, you can do just that, thanks to SNS’ remarkable ability to send messages over SMS. Here’s what you need:
- Access to an AWS account
- The AWS CLI
- IAM role that can perform
sns:Publish
- A named profile configured to use your IAM role.
Once you have all that, sending a text message with SNS is as simple as:
You can scriptify this:
lmk.sh:
And use:
Easy!
You can now concentrate on whatever task you moved on to and know that when your build/migration/whatever is done you’ll get a nice little reminder on your phone.
Caveat: SMS through SNS is supported in a limited set of regions and countries. See the docs for a list.