LambdaAuthorizerProps

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

Bases: object

Base properties for all lambda authorizers.

Parameters:
ExampleMetadata:

fixture=_generated

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_: lambda.Function
# role: iam.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.

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

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}.

results_cache_ttl

How long APIGateway should cache the results.

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

Default:

Duration.minutes(5)