Class: AWSCDK::BedrockAgentCore::LambdaInterceptor

Inherits:
Jsii::Object
  • Object
show all
Includes:
IInterceptor
Defined in:
bedrock_agent_core/lambda_interceptor.rb

Overview

A Lambda-based interceptor for Gateway.

Interceptors allow you to run custom code during each invocation of your gateway:

  • REQUEST interceptors execute before calling the target
  • RESPONSE interceptors execute after the target responds

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ LambdaInterceptor

Returns a new instance of LambdaInterceptor.

Raises:

  • (NoMethodError)


16
17
18
# File 'bedrock_agent_core/lambda_interceptor.rb', line 16

def initialize(*args)
  raise NoMethodError, "aws-cdk-lib.aws_bedrockagentcore.LambdaInterceptor does not have a visible constructor; use the provided factory methods"
end

Class Method Details

.for_request(lambda_function, options = nil) ⇒ AWSCDK::BedrockAgentCore::LambdaInterceptor

Create a REQUEST interceptor that executes before the gateway calls the target.

Important: When this interceptor is added to a gateway, the gateway's IAM role will automatically be granted lambda:InvokeFunction permission on the specified Lambda function.

Parameters:

Returns:

  • (AWSCDK::BedrockAgentCore::LambdaInterceptor)

    A configured LambdaInterceptor for request interception



36
37
38
39
40
41
# File 'bedrock_agent_core/lambda_interceptor.rb', line 36

def self.for_request(lambda_function, options = nil)
  Jsii::Type.check_type(lambda_function, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklGdW5jdGlvbiJ9")), "lambdaFunction")
  options = options.is_a?(Hash) ? ::AWSCDK::BedrockAgentCore::InterceptorOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYmVkcm9ja2FnZW50Y29yZS5JbnRlcmNlcHRvck9wdGlvbnMifQ==")), "options") unless options.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_bedrockagentcore.LambdaInterceptor", "forRequest", [lambda_function, options])
end

.for_response(lambda_function, options = nil) ⇒ AWSCDK::BedrockAgentCore::LambdaInterceptor

Create a RESPONSE interceptor that executes after the target responds.

Important: When this interceptor is added to a gateway, the gateway's IAM role will automatically be granted lambda:InvokeFunction permission on the specified Lambda function.

Parameters:

Returns:

  • (AWSCDK::BedrockAgentCore::LambdaInterceptor)

    A configured LambdaInterceptor for response interception



52
53
54
55
56
57
# File 'bedrock_agent_core/lambda_interceptor.rb', line 52

def self.for_response(lambda_function, options = nil)
  Jsii::Type.check_type(lambda_function, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklGdW5jdGlvbiJ9")), "lambdaFunction")
  options = options.is_a?(Hash) ? ::AWSCDK::BedrockAgentCore::InterceptorOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYmVkcm9ja2FnZW50Y29yZS5JbnRlcmNlcHRvck9wdGlvbnMifQ==")), "options") unless options.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_bedrockagentcore.LambdaInterceptor", "forResponse", [lambda_function, options])
end

.jsii_overridable_methodsObject



20
21
22
23
24
25
# File 'bedrock_agent_core/lambda_interceptor.rb', line 20

def self.jsii_overridable_methods
  {
    :interception_point => { kind: :property, name: "interceptionPoint", is_optional: false },
    :bind => { kind: :method, name: "bind", is_optional: false },
  }
end

Instance Method Details

#bind(_scope, gateway) ⇒ AWSCDK::BedrockAgentCore::InterceptorBindConfig

Binds this Lambda interceptor to a Gateway.

This method:

  1. Grants the Gateway's IAM role permission to invoke the Lambda function
  2. Returns the CloudFormation configuration for this interceptor

Parameters:

  • _scope (Constructs::Construct)

    The construct scope (currently unused, reserved for future extensions).

  • gateway (AWSCDK::BedrockAgentCore::IGateway)

    The gateway this interceptor is being bound to.

Returns:



76
77
78
79
80
# File 'bedrock_agent_core/lambda_interceptor.rb', line 76

def bind(_scope, gateway)
  Jsii::Type.check_type(_scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "_scope")
  Jsii::Type.check_type(gateway, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYmVkcm9ja2FnZW50Y29yZS5JR2F0ZXdheSJ9")), "gateway")
  jsii_call_method("bind", [_scope, gateway])
end

#interception_pointAWSCDK::BedrockAgentCore::InterceptionPoint

The interception point (REQUEST or RESPONSE).



62
63
64
# File 'bedrock_agent_core/lambda_interceptor.rb', line 62

def interception_point()
  jsii_get_property("interceptionPoint")
end