Authenticate Lambda Requests with ALB and Google OAuth: Part 2

Authenticate Lambda requests with an Application Load Balancer with Infrastructure as Code.

General Architecture

Set OAuth Client and Certificate ARN environment variables.

Google ClientID and Client Secret
GOOGLE_WEB_FORUM_CLIENT_ID=<your_client_id>
GOOGLE_WEB_FORUM_CLIENT_SECRET=<your_client_secret>
SSL_CERTIFICATE=<your_certificate_arn>

Serverless Template

CloudFormation Resources

Create a serverless “authorizer”

Attach ALB events to our Lambda services

Format Lambda Responses and Errors

Returning Successful Responses

Returning Errors

ConditionalCheckFailedException: Forum, "Secure Forum", already exists.

Create a Route53 Alias Record that routes traffic to the Application Load Balancer

$ yarn build-deploy
Create an A Record for the Application Load Balancer

Test Your ALB-Authenticated Services!

JSON-formatted response for the request

Additions

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store