aws-cdk-lib.aws_appsync.LambdaAuthorizerConfig

interface LambdaAuthorizerConfig

LanguageType name
.NETAmazon.CDK.AWS.AppSync.LambdaAuthorizerConfig
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsappsync#LambdaAuthorizerConfig
Javasoftware.amazon.awscdk.services.appsync.LambdaAuthorizerConfig
Pythonaws_cdk.aws_appsync.LambdaAuthorizerConfig
TypeScript (source)aws-cdk-lib » aws_appsync » LambdaAuthorizerConfig

Configuration for Lambda authorization in AppSync.

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

Example

import * as lambda from 'aws-cdk-lib/aws-lambda';
declare const authFunction: lambda.Function;

new appsync.GraphqlApi(this, 'api', {
  name: 'api',
  schema: appsync.SchemaFile.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
  authorizationConfig: {
    defaultAuthorization: {
      authorizationType: appsync.AuthorizationType.LAMBDA,
      lambdaAuthorizerConfig: {
        handler: authFunction,
        // can also specify `resultsCacheTtl` and `validationRegex`.
      },
    },
  },
});

Properties

NameTypeDescription
handlerIFunctionThe authorizer lambda function.
resultsCacheTtl?DurationHow long the results are cached.
validationRegex?stringA regular expression for validation of tokens before the Lambda function is called.

handler

Type: IFunction

The authorizer lambda function.

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


resultsCacheTtl?

Type: Duration (optional, default: Duration.minutes(5))

How long the results are cached.

Disable caching by setting this to 0.


validationRegex?

Type: string (optional, default: no regex filter will be applied.)

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