InterceptorOptions
- class aws_cdk.aws_bedrock_agentcore_alpha.InterceptorOptions(*, pass_request_headers=None)
Bases:
object(experimental) Options for configuring an interceptor.
- Parameters:
pass_request_headers (
Optional[bool]) – (experimental) Whether to pass request headers to the interceptor Lambda function. Security Warning: Request headers can contain sensitive information such as authentication tokens and credentials. Only enable this if your interceptor needs access to headers and you have verified that sensitive information is not logged or exposed. Default: false - Headers are not passed to interceptor for security- Stability:
experimental
- ExampleMetadata:
fixture=default infused
Example:
# Create Lambda functions for interceptors request_interceptor_fn = lambda_.Function(self, "RequestInterceptor", runtime=lambda_.Runtime.PYTHON_3_12, handler="index.handler", code=lambda_.Code.from_inline(""" def handler(event, context): # Validate and transform request return { "interceptorOutputVersion": "1.0", "mcp": { "transformedGatewayRequest": event["mcp"]["gatewayRequest"] } } """) ) response_interceptor_fn = lambda_.Function(self, "ResponseInterceptor", runtime=lambda_.Runtime.PYTHON_3_12, handler="index.handler", code=lambda_.Code.from_inline(""" def handler(event, context): # Filter or transform response return { "interceptorOutputVersion": "1.0", "mcp": { "transformedGatewayResponse": event["mcp"]["gatewayResponse"] } } """) ) # Create gateway with interceptors gateway = agentcore.Gateway(self, "MyGateway", gateway_name="my-gateway", interceptor_configurations=[ agentcore.LambdaInterceptor.for_request(request_interceptor_fn, pass_request_headers=True ), agentcore.LambdaInterceptor.for_response(response_interceptor_fn) ] )
Attributes
- pass_request_headers
(experimental) Whether to pass request headers to the interceptor Lambda function.
Security Warning: Request headers can contain sensitive information such as authentication tokens and credentials. Only enable this if your interceptor needs access to headers and you have verified that sensitive information is not logged or exposed.
- Default:
false - Headers are not passed to interceptor for security
- Stability:
experimental