GithubHelp home page GithubHelp logo

dhruv4 / serverless-reddit-headline-sms Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ranek/serverless-reddit-headline-sms

0.0 1.0 0.0 5 KB

Send a daily headline from reddit via SMS, using AWS Lambda.

License: MIT License

Python 100.00%

serverless-reddit-headline-sms's Introduction

serverless-reddit-headline-sms

This is an AWS Lambda function that fetches a daily top headline from reddit. Using Amazon Simple Notification Service, it is able to send an SMS each day to a pre-configured phone number.

Please note that SNS only supports SMS messaging in a subset of regions. Please see the linked support document to ensure you deploy this application in a supported region.

Deployment

Deploying this serverless app to your AWS account is quick and easy using AWS CloudFormation.

Packaging

With the AWS CLI installed, run the following command to upload the code to S3. You need to re-run this if you change the code in archiver.py. Be sure to set DEPLOYMENT_S3_BUCKET to a bucket you own; CloudFormation will copy the code function into a ZIP file in this S3 bucket, which can be deployed to AWS Lambda in the following steps.

DEPLOYMENT_S3_BUCKET="YOUR_S3_BUCKET"
aws cloudformation package --template-file cloudformation.yaml --s3-bucket $DEPLOYMENT_S3_BUCKET \
  --output-template-file cloudformation-packaged.yaml

Now you will have cloudformation-packaged.yaml, which contains the full path to the ZIP file created by the previous step.

Configuring

Next, let's set the required configuration. You can set the following parameters:

  • STACK_NAME is the name of the CloudFormation stack that you'll create to manage all the resources (Lambda functions, CloudWatch Events) associated with this app. You can set this to a new value to create a new instance with different parameters in your account, or use the same value when re-running to update parameters of an existing deployment.
  • PHONE_NUMBER is the recipient of the daily headline. Use E.164 (e.g. +15555550100) format.
  • UTC_HOUR is the UTC hour at which to send the headline.
  • SUBREDDIT is the subreddit to scan, without the /r/. e.g. worldnews.
STACK_NAME="serverless-reddit-headline-sms"
PHONE_NUMBER="+12068007270"
UTC_HOUR="10"
SUBREDDIT="worldnews"

With these configuration parameters defined, we can call cloudformation deploy to create the necessary resources in your AWS account:

aws cloudformation deploy --template-file cloudformation-packaged.yaml --capabilities CAPABILITY_IAM \
  --parameter-overrides \
  "PhoneNumber=$PHONE_NUMBER" \
  "UTCHour=$UTC_HOUR" \
  "Subreddit=$SUBREDDIT" \
  --stack-name $STACK_NAME

If all went well, your stack has now been created. Next time the clock strikes $UTC_HOUR, you should look forward to a headline from $SUBREDDIT at $PHONE_NUMBER!

serverless-reddit-headline-sms's People

Contributors

ranek avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.