Class: AWSCDK::APIGateway::LambdaAuthorizerProps

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
api_gateway/lambda_authorizer_props.rb

Overview

Base properties for all lambda authorizers.

Direct Known Subclasses

RequestAuthorizerProps, TokenAuthorizerProps

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler:, assume_role: nil, authorizer_name: nil, results_cache_ttl: nil) ⇒ LambdaAuthorizerProps

Returns a new instance of LambdaAuthorizerProps.

Parameters:

  • handler (AWSCDK::Lambda::IFunction)

    The handler for the authorizer lambda function.

  • assume_role (AWSCDK::IAM::IRole, nil) (defaults to: nil)

    An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.

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

    An optional human friendly name for the authorizer.

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

    How long APIGateway should cache the results.



11
12
13
14
15
16
17
18
19
20
# File 'api_gateway/lambda_authorizer_props.rb', line 11

def initialize(handler:, assume_role: nil, authorizer_name: nil, results_cache_ttl: nil)
  @handler = handler
  Jsii::Type.check_type(@handler, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklGdW5jdGlvbiJ9")), "handler")
  @assume_role = assume_role
  Jsii::Type.check_type(@assume_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "assumeRole") unless @assume_role.nil?
  @authorizer_name = authorizer_name
  Jsii::Type.check_type(@authorizer_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "authorizerName") unless @authorizer_name.nil?
  @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?
end

Instance Attribute Details

#assume_roleAWSCDK::IAM::IRole? (readonly)

Note:

Default: - A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.

An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.

The IAM role must be assumable by 'apigateway.amazonaws.com'.

Returns:



38
39
40
# File 'api_gateway/lambda_authorizer_props.rb', line 38

def assume_role
  @assume_role
end

#authorizer_nameString? (readonly)

Note:

Default: - the unique construct ID

An optional human friendly name for the authorizer.

Note that, this is not the primary identifier of the authorizer.

Returns:

  • (String, nil)


45
46
47
# File 'api_gateway/lambda_authorizer_props.rb', line 45

def authorizer_name
  @authorizer_name
end

#handlerAWSCDK::Lambda::IFunction (readonly)

The handler for the authorizer lambda function.

The handler must follow a very specific protocol on the input it receives and the output it needs to produce. API Gateway has documented the handler's input specification and output specification.



30
31
32
# File 'api_gateway/lambda_authorizer_props.rb', line 30

def handler
  @handler
end

#results_cache_ttlAWSCDK::Duration? (readonly)

Note:

Default: - Duration.minutes(5)

How long APIGateway should cache the results.

Max 1 hour. Disable caching by setting this to 0.

Returns:



53
54
55
# File 'api_gateway/lambda_authorizer_props.rb', line 53

def results_cache_ttl
  @results_cache_ttl
end

Class Method Details

.jsii_propertiesObject



55
56
57
58
59
60
61
62
# File 'api_gateway/lambda_authorizer_props.rb', line 55

def self.jsii_properties
  {
    :handler => "handler",
    :assume_role => "assumeRole",
    :authorizer_name => "authorizerName",
    :results_cache_ttl => "resultsCacheTtl",
  }
end

Instance Method Details

#to_jsiiObject



64
65
66
67
68
69
70
71
72
73
# File 'api_gateway/lambda_authorizer_props.rb', line 64

def to_jsii
  result = {}
  result.merge!({
    "handler" => @handler,
    "assumeRole" => @assume_role,
    "authorizerName" => @authorizer_name,
    "resultsCacheTtl" => @results_cache_ttl,
  })
  result.compact
end