Class: AWSCDK::AppSync::LambdaAuthorizerConfig

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
app_sync/lambda_authorizer_config.rb

Overview

Configuration for Lambda authorization in AppSync.

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler:, results_cache_ttl: nil, validation_regex: nil) ⇒ LambdaAuthorizerConfig

Returns a new instance of LambdaAuthorizerConfig.

Parameters:

  • handler (AWSCDK::Lambda::IFunction)

    The authorizer lambda function.

  • results_cache_ttl (AWSCDK::Duration, nil) (defaults to: nil)

    How long the results are cached.

  • validation_regex (String, nil) (defaults to: nil)

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



12
13
14
15
16
17
18
19
# File 'app_sync/lambda_authorizer_config.rb', line 12

def initialize(handler:, results_cache_ttl: nil, validation_regex: nil)
  @handler = handler
  Jsii::Type.check_type(@handler, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklGdW5jdGlvbiJ9")), "handler")
  @results_cache_ttl = results_cache_ttl
  Jsii::Type.check_type(@results_cache_ttl, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "resultsCacheTtl") unless @results_cache_ttl.nil?
  @validation_regex = validation_regex
  Jsii::Type.check_type(@validation_regex, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "validationRegex") unless @validation_regex.nil?
end

Instance Attribute Details

#handlerAWSCDK::Lambda::IFunction (readonly)

The authorizer lambda function.



25
26
27
# File 'app_sync/lambda_authorizer_config.rb', line 25

def handler
  @handler
end

#results_cache_ttlAWSCDK::Duration? (readonly)

Note:

Default: Duration.minutes(5)

How long the results are cached.

Disable caching by setting this to 0.

Returns:



32
33
34
# File 'app_sync/lambda_authorizer_config.rb', line 32

def results_cache_ttl
  @results_cache_ttl
end

#validation_regexString? (readonly)

Note:

Default: - no regex filter will be applied.

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

Returns:

  • (String, nil)


37
38
39
# File 'app_sync/lambda_authorizer_config.rb', line 37

def validation_regex
  @validation_regex
end

Class Method Details

.jsii_propertiesObject



39
40
41
42
43
44
45
# File 'app_sync/lambda_authorizer_config.rb', line 39

def self.jsii_properties
  {
    :handler => "handler",
    :results_cache_ttl => "resultsCacheTtl",
    :validation_regex => "validationRegex",
  }
end

Instance Method Details

#to_jsiiObject



47
48
49
50
51
52
53
54
55
# File 'app_sync/lambda_authorizer_config.rb', line 47

def to_jsii
  result = {}
  result.merge!({
    "handler" => @handler,
    "resultsCacheTtl" => @results_cache_ttl,
    "validationRegex" => @validation_regex,
  })
  result.compact
end