Data producer

Most of the complexities in this code revolve around the Twitter API, which I won't go into in detail. I haven't worked with the Twitter API much myself, but the tweepy GitHub page and website have plenty of resources and example code to get you started, which is just what I followed to get this working. The following code is the entry point to the entire process, which begins reading the public Twitter stream for tweets related to cats or dogs and placing a subset of each tweet onto the SQS queue: 

import osimport tweepyfrom .queue import publish_tweetconsumer_key = os.environ['TWITTER_CONSUMER_KEY']consumer_secret = os.environ['TWITTER_CONSUMER_SECRET']access_token = os.environ['TWITTER_ACCESS_TOKEN']access_token_secret = ...

Get Serverless Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.