LambdaAuthorizerConfig

class aws_cdk.aws_appsync.LambdaAuthorizerConfig(*, handler, results_cache_ttl=None, validation_regex=None)

Bases: object

Configuration for Lambda authorization in AppSync.

Note that you can only have a single AWS Lambda function configured to authorize your API.

Parameters:
  • handler (IFunction) – The authorizer lambda function.

  • results_cache_ttl (Optional[Duration]) – How long the results are cached. Disable caching by setting this to 0. Default: Duration.minutes(5)

  • validation_regex (Optional[str]) – A regular expression for validation of tokens before the Lambda function is called. Default: - no regex filter will be applied.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_lambda as lambda_
# auth_function: lambda.Function


appsync.GraphqlApi(self, "api",
    name="api",
    definition=appsync.Definition.from_file(path.join(__dirname, "appsync.test.graphql")),
    authorization_config=appsync.AuthorizationConfig(
        default_authorization=appsync.AuthorizationMode(
            authorization_type=appsync.AuthorizationType.LAMBDA,
            lambda_authorizer_config=appsync.LambdaAuthorizerConfig(
                handler=auth_function
            )
        )
    )
)

Attributes

handler

The authorizer lambda function.

See:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-lambdaauthorizerconfig.html

results_cache_ttl

How long the results are cached.

Disable caching by setting this to 0.

Default:

Duration.minutes(5)

validation_regex

A regular expression for validation of tokens before the Lambda function is called.

Default:
  • no regex filter will be applied.