September 12, 2021

Mirror HTTP request using ALB backed by AWS Lambda

When Gonzalo Diethelm asked me whether there is a way to echo the http request to validate Lambda@Edge functions that modifies the request by adding / updating / deleting headers? I couldn’t find something that’s already available. Hence I quickly created a simple Lambda function front-ended by Application Load Balancer to just return the response that it has recieved.

Summary:

Below is the quick overview of the solution.
Solutions Design diagram explaining how the solution is structured A simple AWS lambda function which recieves the HTTP request from the Application Load Balancer and returns the same back which includes the HTTP verb, path, headers, query string parameters, and body as a JSON response. This ALB shall be configured as the origin for your Amazon CloudFront distribution with Lambda@Edge function attached to it.

Deploying the solution:

You can deploy the solution using the following CloudFormation template.

Parameteres to CloudFormation template:

  • Subnets - Select two or more public subnets
  • VpcId - Select the VPC Id to which the above mentioned subnets belong
  • ConcurrencyLimit - Enter the maximum number of concurrency requests allowed to Lambda function

This would cost approximately $20 per month for running this ALB & Lambda for testing purposes.

Clean Up:
To clean up the resources delete the CloudFormation stack that you have created.

© Prakash P 2015 - 2023

Powered by Hugo & Kiss.