About this Article
Describes a setting to allow the authorizer to be used by multiple Lambdas when deploying Lambdas using the Serverless Framework.
procedure
Include resultTtlInSeconds: 0 in all http events that use the authorizer, as in Described in the official manual.
Note that the authorizer's cache will not be disabled if you do not mention it in all
serverless.yml
functions: create: handler: posts.create events: - http: path: posts/create method: post authorizer: name: authorizerFunc resultTtlInSeconds: 0
explanation
If the authorizer cache is enabled, when the authorizer is called from multiple http events, the cache of other http events will be referenced even if the http events are different, so the authorizer cache must be disabled.
In the Serverless Framework, follow the above procedure to disable the authorizer cache.
Note that if even one of the resultTtlInSeconds: 0 settings is left out, the cache will be set.
Originally, API Gateway authorizer cache settings are configured in the authorizer definition, but in the Serverless Framework, settings cannot be configured in the authorizer definition (even if AuthorizerResultTtlInSeconds, authorizerResultTtlInSeconds, or authorizerResultTtlInSeconds is written, it will not work). However, in the Serverless Framework, the authorizer cannot be set in the authorizer definition (even if AuthorizerResultTtlInSeconds or resultTtlInSeconds is written, it will not work), but is automatically set based on the setting status of http events.