Skip to content

Project to create leaderboard with AWS S3 Lambda DynamoDB and API Gateway

Notifications You must be signed in to change notification settings

coursecoder/leaderboard-aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation

Introduction

The purpose of this work is to develop and deploy a leaderboard for your game using the following AWS resources: S3, APIGateway, Lambda, IAM, and DynamoDB. The choice of a highly available, scalable, and secure serverless environment with massive economies of scale will have several benefits to the end user, including:

  • low product pricing
  • fast response time, and
  • reliable uptime

Leaderboard Architecture

Playdough AWS Architecture

Project Organization

  • python_3 Folder: This folder contains all python scripts that are used to build AWS infrastructure on the backend.
  • resources Folder: This folder contains the initial setup script as well as the infrastructure for the frontend.
    • website Folder: This folder contains all the images and code necessary to build a functional game with leaderboard. Click the image below to see a live demo of what will be created.

Click to see live example

Requirements

  • AWS CLI: See the Getting started guide in the AWS CLI User Guide for more information.
  • AWS Credentials: Your AWS credentials need to have administrative privileges to IAM, S3, Lambda, API Gateway and DynamoDB. If you haven’t setup AWS credentials before, this resource from AWS is helpful.
  • AWS SDK for Python: You will need to be running the latest Boto3 release. See the Boto3 Quickstart for more information.

Installation Instructions

Step 1: Clone the repo

git clone https://github.com/coursecoder/leaderboard-aws.git

Step 2: Run setup script

  • Set permissions on the script so that you can run it, and then run it:
chmod +x ./resources/setup.sh && ./resources/setup.sh
  • You will be asked to name your S3 bucket. Your bucket name must be appended with -leaderboard for the script to work. If you are not familiar with naming S3 buckets, see Bucket Naming Rules.

The setup script creates the following resources:

  1. An S3 bucket with an associated bucket policy. The bucket contains the game website code.
  2. An Amazon DynamoDB table populated with leaderboard data. The leaderboard is already pre-seeded with 25 users (json file is resources/website/all_gamers.json). The leaderboard avatars are generated using the 3rd party API DiceBear Avatars.
  3. A REST API configured using Amazon API Gateway.
    • All game data is exposed at /leaderboard (GET)
    • Data for the top six players is exposed at /leaderboard/top_players (GET)
    • Score submission endpoint is exposed at /score/submit (POST).
  4. Two Lambda functions are created
    • get_all_leaderboard function is used by the two GET endpoints to retrieve data from DynamoDB when invoked. There is a policy that gives the Lambda function permission to read data from DynamoDB.
    • submit_score function is used by the POST endpoint to put data to DynamoDB. The policy gives the Lambda function permission to update the DynamoDB data.

About

Project to create leaderboard with AWS S3 Lambda DynamoDB and API Gateway

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published