Interface LambdaAuthorizerConfig

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
LambdaAuthorizerConfig.Jsii$Proxy

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:49.525Z") @Stability(Experimental) public interface LambdaAuthorizerConfig extends software.amazon.jsii.JsiiSerializable
(experimental) Configuration for Lambda authorization in AppSync.

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

Example:

 import software.amazon.awscdk.services.lambda.*;
 Function authFunction;
 GraphqlApi.Builder.create(this, "api")
         .name("api")
         .schema(Schema.fromAsset(join(__dirname, "appsync.test.graphql")))
         .authorizationConfig(AuthorizationConfig.builder()
                 .defaultAuthorization(AuthorizationMode.builder()
                         .authorizationType(AuthorizationType.LAMBDA)
                         .lambdaAuthorizerConfig(LambdaAuthorizerConfig.builder()
                                 .handler(authFunction)
                                 .build())
                         .build())
                 .build())
         .build();
 
  • Method Details

    • getHandler

      @Stability(Experimental) @NotNull IFunction getHandler()
      (experimental) The authorizer lambda function.

      Note: This Lambda function must have the following resource-based policy assigned to it. When configuring Lambda authorizers in the console, this is done for you. To do so with the AWS CLI, run the following:

      aws lambda add-permission --function-name "arn:aws:lambda:us-east-2:111122223333:function:my-function" --statement-id "appsync" --principal appsync.amazonaws.com --action lambda:InvokeFunction

      See Also:
    • getResultsCacheTtl

      @Stability(Experimental) @Nullable default Duration getResultsCacheTtl()
      (experimental) How long the results are cached.

      Disable caching by setting this to 0.

      Default: Duration.minutes(5)

    • getValidationRegex

      @Stability(Experimental) @Nullable default String getValidationRegex()
      (experimental) A regular expression for validation of tokens before the Lambda function is called.

      Default: - no regex filter will be applied.

    • builder

      @Stability(Experimental) static LambdaAuthorizerConfig.Builder builder()
      Returns:
      a LambdaAuthorizerConfig.Builder of LambdaAuthorizerConfig