Serverless Spotify Playlist Updates

rohanmehta_dev

Rohan

Posted on November 12, 2019

Serverless Spotify Playlist Updates

Ever wonder if you could get notified when new songs are added to a Spotify playlist?

I made a Twitter bot using node.js that tweets out new songs added to Spotify's POLLEN playlist.
Link to Github Repo: Github Repo

Tools and Frameworks used:

App Workflow:
Alt Text

  1. CloudWatch Events Rule is set to trigger the Lambda function once an hour.
  2. Lambda function retrieves all songs Spotify's POLLEN playlist.
  3. If a song is not currently in the DynamoDB table, add the song to the table.
  4. For each new song, post a tweet with the artist name, song title, and link to the song.

My Thoughts:

  • Why is this a good use case for AWS Lambda? Given that I'm only running the CloudWatch Events Rule once an hour, I don't need to manage a server and run a web app 24/7. It's easier and cheaper to use a Lambda function since the code will run only when invoked.
  • I've used Lambda before but this was my first time using the Serverless Framework. I found it very useful to be able to invoke my function locally before deploying to AWS.
  • Initially I planned to use the npm package Lowdb to store the songs within my Lambda file but I then read Lambda functions should be stateless and any persistent state information should be kept in a separate database. This was the first time I used DynamoDB in a personal project. I found it quite easy to use the aws-sdk npm package to upload data to my DynamoDB table.

Next Steps:

Useful Links:

Please feel free to leave questions or comments below!

💖 💪 🙅 🚩
rohanmehta_dev
Rohan

Posted on November 12, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Serverless Spotify Playlist Updates
serverless Serverless Spotify Playlist Updates

November 12, 2019