lmammino / fm.loige.co

The Rusty serverless API that powers fm.loige.co. Developed with AWS Lambda, Rust and SAM.

Home Page:https://loige.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fm.loige.co

Rust Sam

The Rusty serverless API that powers fm.loige.co. Developed with AWS Lambda, Rust and SAM.

If you want to build something like this for yourself, you can use this repo as a reference and follow the instructions below.

Requirements

It requires a Last.fm account and a Last.fm API key.

If you want to deploy it on AWS you need an AWS account and the AWS CLI installed and configured.

You'll also need the Rust toolchain, cargo-lambda, Docker, and SAM installed on your machine.

Usage

First of all, grab an API key and make sure to populate the LASTFM_API_KEY environment variable with it.

Running locally

To run the Lambda locally you can use cargo lambda:

$ cargo lambda watch

This will spin up a development server to which you can send requests. For example:

$ cargo lambda invoke --data-file events/example-apigw-request.json

If you want to run this as a local API, you can do that with SAM:

$ sam local start-api

Then you can send requests to http://localhost:3000/playing.

Deploying on AWS

Before deploying to AWS you most likely want to customise the template.yaml.

In particular, you will want to change all the various parameters. I am also using a custom domain name, so you'll want to change that as well.

Domain name requires validation, so when the first deployment starts, it will stay in a pending state until you create the necessary DNS records to validate the TLS certificate. This can be done manually or by logging in the AWS console and going to the Certificate Manager service.

Note: This is only necessary for the first deployment

Once you are happy with the configuration, you can deploy the stack with:

$ sam deploy --guided

And follow the guided procedure.

Contributing

Everyone is very welcome to contribute to this project. You can contribute just by submitting bugs or suggesting improvements by opening an issue on GitHub.

License

Licensed under MIT License. © Luciano Mammino.

About

The Rusty serverless API that powers fm.loige.co. Developed with AWS Lambda, Rust and SAM.

https://loige.co

License:MIT License


Languages

Language:Rust 97.0%Language:Shell 3.0%