Authorization Lambda caching based on api-key and path

0

I have an Authorization Lambda for my API Gateway.

This Lambda will take an api-key in the header, and the event.path, that is, the requested path, and based on this combination will either allow the request to proceed or return a 403 Forbidden.

I want to enable Authorization Caching, however, it's not clear to me how the keys in the cache are formed. I want the cache key to consider both the api-key and the requested path, how can I do this?

Sergio
asked 2 years ago1554 views
1 Answer
2

Assuming that this is a REST API and a REQUEST type Lambda, the default cache key used for Lambda authorizers is the resource path.

On REQUEST type Lambda authorizers, you have the ability to define “identity sources” which are used to create the cache key.

When multiple identity sources are defined they are used in combination to create the cache key.

You can define the identity sources in the Lambda Event Payload (you can find this in the Edit Authorizer settings) in order to create a cache key based on the resource path as well as the value of the x-api-key header.

AWS
SUPPORT ENGINEER
Tim_P
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions