Skip to content

Trigger fabric tasks on your server through SMS and AWS Lambda.

License

Notifications You must be signed in to change notification settings

marteinn/sms-server-remote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMS-Server-Remote

This is a experiment based on Twilio and Serverless that lets you trigger fabric tasks on your server through SMS.

Getting started

  • [Install serverless](: npm install serverless -g)
  • Setup project on AWS (just follow the serverless instructions)
  • Update dependencies: make update_dependencies
  • Write your own fabfile and server handling, store it in src/incoming/sms/config (I have included a example for clarification)
  • Deploy the function and endpoint incoming_sms
  • Create a Twilio TwiML app that handles SMS messaging, use your lambda endpoint as request url with HTTP GET

Usage

  • Send a SMS with your fabric command to your Twilio phone number (example: prod restart_apache)

  • Sends back something like this:

    service apache restart
    restarting apache..
    restart complete!
    
  • Please note: Fabric taks that takes longer then 15 seconds are not sent back to Twilio (due to Twilio timeout limitations)

Endpoints: incoming_sms

The endpoint incoming_sms requires the following params:

  • Body (SMS message body delivered from Twilio)
  • From (Phone number delivered from Twilio)
  • secret (A simple auth token)

Example:

curl -X "GET" "https://XXXXX.execute-api.eu-west-1.amazonaws.com/stage/incoming_sms?Body=mp%20info&From=%2B46000000&secret=myscret"

Returns:

<Response>
  <Message>
    <Body><![CDATA[cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"
NAME="Ubuntu"
VERSION="14.04.4 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.4 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"]]></Body>
  </Message>
</Response>

Git hooks

Bump version

These hooks will automatically bump the application version when using git flow release ...

chmod +x $PWD/git-hooks/bump-version.sh
ln -nfs $PWD/git-hooks/bump-version.sh .git/hooks/post-flow-release-start
ln -nfs $PWD/git-hooks/bump-version.sh .git/hooks/post-flow-hotfix-start

Commands

  • Deploy function: npm run serverless function deploy -a
  • Deploy endpoint: npm run serverless endpoint deploy -a
  • Deploy: npm run serverless dash deploy

Dependencies

References

Tutorials/Examples

Contributing

Want to contribute? Awesome. Just send a pull request.

License

sms-server-remote is released under the MIT License.

About

Trigger fabric tasks on your server through SMS and AWS Lambda.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published