Giter Site home page Giter Site logo

terraform-aws-api-gateway-with-auth's Introduction

REST API made with Terraform

  • Very Simple example of setting up an AWS API Gateway with a Custom Authorizer to only allow request that contain Authorization: Bearer <anything-here> header.
  • NOTE: you should update logic in the Custom Authorizer to hit an authorizatin server to parse the JWT
  • Here are a few JSON Web Token (JWT) authentication services:
    1. Auth0: A cloud-based platform that provides identity management and authentication services, including JWT authentication.
    2. Okta: A cloud-based identity and access management platform that provides JWT authentication as part of its services.
    3. Firebase Authentication: A service provided by Google Firebase that provides JWT authentication for mobile and web applications.
    4. Microsoft Azure Active Directory B2C: A cloud-based identity and access management service provided by Microsoft that supports JWT authentication.
    5. AWS Cognito: An Amazon Web Services service that provides JWT authentication for web and mobile applications.
    6. JWT.io: An open-source platform that provides JWT authentication services and tools, including a JWT debugger and generator.

How to get started

Setup

  1. In AWS create a S3 Bucket with the format terraform-remote-config-<AWS_ACCOUNT_ID>, this will house all your remote terraform state in separate workspaces. Manually create this for each AWS account you want to run this. We are creating this manually because we can leverage this S3 bucket for other projects
  2. Create a .env.local with 2 values
AWS_ACCOUNT_ID="000000000000"
AWS_PROFILE="default" # ?? most likely you are using the "default" profile
  1. Install Terraform with at least version 1.3. TFSwitch is a great terraform version manager you might want to look into using.

Deploy/Destroy all the AWS resources

# Deploy with (dev|stage|prod)
$ ./deploy.sh dev

# Destroy with (dev|stage|prod)
$ ./kill.sh dev

How to test

  • After the terraform code has been run once it will create a .env file with account_id, base_url, function_name where you can make a PostMan or if you are using vscode you can install an rest-client extension and run the ./rest.http file (which consumes the .env file)

Test to see if CORS is enabled with a React app

  • Add the REST URI to line 5 of ./client-testing-the-service/src/App.jsx, (when you run the ./deploy.sh dev the URI is writen to your .env file)

terraform-aws-api-gateway-with-auth's People

Watchers

philopian 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.