GithubHelp home page GithubHelp logo

breyr / simpleawsotp Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 202 KB

Template for an OTP system hosted on AWS

License: MIT License

Python 100.00%
aws-apigateway aws-dynamodb aws-lambda aws-ses python

simpleawsotp's Introduction

AWS Infrastructure Documentation

Table of Contents

Introduction

This documentation serves as a guide for understanding and hosting a simple OTP verification service on AWS.

Architecture

Architecture Diagram

The architecture diagram above illustrates the components and connections needed to host this service on AWS.

Services

AWS Lambda

GenerateOTP

  • Trigger: API Gateway - POST request
  • Functionality: Stores email and otp in DynamoDB with a ttl attribute set to expire after 5 minutes.

SendOTPEmail

  • Trigger: DynamoDB Stream (Filters for INSERT events)
  • Functionality: Uses SES to send an email when an OTP is generated.

VerifyOTP

  • Trigger: API Gateway - POST request
  • Functionality: Verifies otp against DynamoDB.

API Gateway

HTTP API Gateway with 2 routes:

  • /GenerateOTP (POST - GenerateOTP Lambda Function)
  • /VerifyOTP (POST - VerifyOTP Lambda Function)

DynamoDB

EmailVerification Table

  • Primary Key: email (string)
  • otp (6-digit random string generated)
  • ttl (time to live - Number)
  • Stream enabled
  • TTL enabled for ttl attribute

Cloudflare Pages

  • Set up for static website hosting.

SES (Simple Email Service)

CloudWatch

  • Logs, Events, Metrics auto-configured for Lambda functions.

Policies

Policy for GenerateOTP Lambda Function - DynamoRW

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DynamoReadWriteAccess",
      "Effect": "Allow",
      "Action": ["dynamodb:PutItem", "dynamodb:GetItem"],
      "Resource": "arn:aws:dynamodb:<region>:<aws-account-id>:table/EmailVerification"
    }
  ]
}

Policies for VerifyOTP Lambda Function - DynamoRD

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DynamoReadDeleteAccess",
      "Effect": "Allow",
      "Action": ["dynamodb:DeleteItem", "dynamodb:GetItem"],
      "Resource": "arn:aws:dynamodb:<region>:<aws-account-id>:table/EmailVerification"
    }
  ]
}

Policies for SendOTPEmail Lambda Function - ReadDynamoDBStream & SendEmail

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DynamoDBStreamAccess",
      "Effect": "Allow",
      "Action": [
        "dynamodb:GetShardIterator",
        "dynamodb:DescribeStream",
        "dynamodb:GetRecords",
        "dynamodb:ListStreams"
      ],
      "Resource": "arn:aws:dynamodb:<region>:<aws-account-id>:table/EmailVerification/stream/*"
    },
    {
      "Sid": "DynamoListStreams",
      "Effect": "Allow",
      "Action": "dynamodb:ListStreams",
      "Resource": "*"
    }
  ]
}
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["ses:SendEmail", "ses:SendRawEmail"],
      "Resource": "*"
    }
  ]
}

Upcoming Features

  • Terraform scripts for infrastructure provisioning

simpleawsotp's People

Contributors

breyr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.