raveeolee / aws-lambda-lastfm-song

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic AWS Lambda endpoint to parse Last.fm last song for a user

GET https://xxxx.amazonaws.com/song?user=test

{
  "artist": "Gojira",
  "track": "The Gift of Guilt"
}

Architecture

The project source includes function code and supporting resources:

  • src/main - A Java function.
  • src/test - A unit test and helper classes.
  • template.yml - An AWS CloudFormation template that creates an application.
  • build.gradle - A Gradle build file.
  • 1-create-bucket.sh, 2-deploy.sh, etc. - Shell scripts that use the AWS CLI to deploy and manage the application.

Use the following instructions to deploy the sample application.

Requirements

If you use the AWS CLI v2, add the following to your configuration file (~/.aws/config):

cli_binary_format=raw-in-base64-out

This setting enables the AWS CLI v2 to load JSON events from a file, matching the v1 behavior.

Setup

Download or clone this repository. To create a new bucket for deployment artifacts, run 1-create-bucket.sh.

$ ./1-create-bucket.sh
 lambda-artifacts-a5e4xmplb5b22e0d

Deploy

To deploy the application, run 2-deploy.sh.

$ ./2-deploy.sh
BUILD SUCCESSFUL in 1s
Successfully packaged artifacts and wrote output template to file out.yml.
Waiting for changeset to be created..
Successfully created/updated stack - java-basic

This script uses AWS CloudFormation to deploy the Lambda functions and an IAM role. If the AWS CloudFormation stack that contains the resources already exists, the script updates it with any changes to the template or function code.

Set up AWS Lambda API Gateway

Connect API gateway to your lambda function.

Test

GET https://xxxx.amazonaws.com/song?user=test

{
  "artist": "Gojira",
  "track": "The Gift of Guilt"
}

Build UI

From WatchUi

Cleanup

To delete the application, run 4-cleanup.sh.

$ ./4-cleanup.sh

About


Languages

Language:Java 65.9%Language:Shell 34.1%