hands-on lab

Secure API Gateway Endpoints with Custom Authorizers

Difficulty: Intermediate
Duration: Up to 1 hour and 30 minutes
Students: 7,697
Rating: 4.4/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

Lab Overview

Amazon API Gateway offers several native authorization mechanisms, such as managed API keys, IAM Roles, and custom authorizers. API Keys (with the help of Usage Plans) can help manage custom throttling and quotas for your API consumers. IAM is a good choice when your consumers require access to AWS resources and you need to manage permissions on a per-user basis. However, custom authorizers give you much more flexibility. With custom authorizers, you can implement any 3rd-party integration and generate very granular authorization policies.

In this Lab, we will learn how to implement a custom authorizer in AWS Lambda to secure your API Gateway Resources.

Lab Objectives

Upon completion of this Lab you will be able to:

  • Understand API Gateway request authorization
  • Explain the advantages of using custom authorizers in API Gateway
  • Create Lambda functions to implement custom authorizers using AWS Lambda blueprints
  • Test custom authorizers using methods appropriate at each stage of deployment

Lab Prerequisites

You should be familiar with:

  • AWS Lambda basics
  • API Gateway basics

The following content can be used to fulfill the prerequisites: 

Updates

May 8th, 2024 - Resolved deployment issue

January 25th, 2024 - Updated to latest Node.js version

October 25th, 2023 - Updated the instructions and screenshots to reflect the latest UI

December 1st, 2022 - Updated the instructions and screenshots to reflect the latest UI

May 12th, 2022 - Updated lab to utilize a Cloud Academy-hosted Linux command-line interface

November 17th, 2021 - Fixed the link to the lambda function complete code listing

January 22nd, 2021 - Updated AWS Lambda lab steps to reflect the latest user interface updates

January 10th, 2019 - Added a validation Lab Step to check the work you perform in the Lab

Nov. 15th, 2018 - Lab completely updated including easier-to-follow instructions, screenshots to match the latest experience, and removal of security warnings in the AWS Console.

Environment before

Environment after

Covered topics

Lab steps

Logging In to the Amazon Web Services Console
Custom Authorizer Use Cases
Creating a Simple API Gateway Endpoint
Implementing Authorization Logic in Lambda
Creating a new Custom Authorizer
Enabling the API Gateway Custom Authorizer
Testing the Secured Endpoint