LambdaAuthorizerProps

class aws_cdk.aws_apigateway.LambdaAuthorizerProps(*, assume_role=None, authorizer_name=None, handler, results_cache_ttl=None)

Bases: object

Base properties for all lambda authorizers.

Parameters

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_apigateway as apigateway
import aws_cdk.aws_iam as iam
import aws_cdk.aws_lambda as lambda_
import aws_cdk.core as cdk

# function_ is of type Function
# role is of type Role

lambda_authorizer_props = apigateway.LambdaAuthorizerProps(
    handler=function_,

    # the properties below are optional
    assume_role=role,
    authorizer_name="authorizerName",
    results_cache_ttl=cdk.Duration.minutes(30)
)

Attributes

assume_role

An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.

The IAM role must be assumable by ‘apigateway.amazonaws.com’.

Default
  • A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.

Return type

Optional[IRole]

authorizer_name

An optional human friendly name for the authorizer.

Note that, this is not the primary identifier of the authorizer.

Default
  • the unique construcrt ID

Return type

Optional[str]

handler

The handler for the authorizer lambda function.

The handler must follow a very specific protocol on the input it receives and the output it needs to produce. API Gateway has documented the handler’s input specification {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html | here} and output specification {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html | here}.

Return type

IFunction

results_cache_ttl

How long APIGateway should cache the results.

Max 1 hour. Disable caching by setting this to 0.

Default

Duration.minutes(5)

Return type

Optional[Duration]