Skip to content
v2.275.0

LambdaAuthorizerConfig Struct ​

Configuration for Lambda authorization in AppSync.

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

Example ​

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

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

Properties ​

handlerIFunctionhandlerIFunctionhandlerIFunctionHandlerIFunctionHandlerIFunctionrequired#
The authorizer lambda function.
resultsCacheTtloptionalDurationresults_cache_ttloptionalDurationresultsCacheTtloptionalDurationResultsCacheTtloptionalDurationResultsCacheTtloptionalDuration= Duration.minutes(5)#
How long the results are cached.

Disable caching by setting this to 0.

validationRegexoptionalstringvalidation_regexoptionalstrvalidationRegexoptionalStringValidationRegexoptionalstringValidationRegexoptional*string#
A regular expression for validation of tokens before the Lambda function is called.

Default: no regex filter will be applied.