Create a custom authorizer with a single Lambda function to the API Gateway in AWS to handle custom authentication integration — Infrastructure as Code (IaC)

When you are working with API Gateway on AWS one of the things there are nice and smooth to do are to integrate your own authorizer layer, you don’t need to use AWS Cognito as an access provider, you can build your authentication integration if you want or already use an existing authorizer provider.

lambdaStack.py

In our Lambda NestedStack file, we are creating 2 Lambda functions and returning the object, one of the Lambda functions is used for our authorizer and the second will be a test Lambda function to confirm our authorizer is working as we expect.

line 13: prepare our HttpLambdaAuthorizer object
line 15: defined the Lambda function object we want to use when a client needs to authorize the access between our route Lambda function and API Gateway request.
line 23: default cache for the authorizer is 5 min, when we are testing I recommend disabling the…

--

--

Paris Nakita Kejser
DevOps Engineer, Software Architect and Software Developering

DevOps Engineer, Software Architect, Software Developer, Data Scientist and identify me as a non-binary person.