GatewayProps Struct
Properties for defining a Gateway.
| Source | aws-bedrockagentcore/lib/gateway/gateway.ts |
|---|---|
| Type last changed |
Example
const gateway = new agentcore.Gateway(this, "MyGateway", {
gatewayName: "my-gateway",
});
const lambdaFunction = new lambda.Function(this, "MyFunction", {
runtime: lambda.Runtime.NODEJS_22_X,
handler: "index.handler",
code: lambda.Code.fromInline(`
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello from Lambda!' })
};
};
`),
});
// Create a gateway target with Lambda and tool schema
const target = agentcore.GatewayTarget.forLambda(this, "MyLambdaTarget", {
gatewayTargetName: "my-lambda-target",
description: "Target for Lambda function integration",
gateway: gateway,
lambdaFunction: lambdaFunction,
toolSchema: agentcore.ToolSchema.fromLocalAsset(
path.join(__dirname, "schemas", "my-tool-schema.json")
),
});
gateway = agentcore.Gateway(self, "MyGateway",
gateway_name="my-gateway"
)
lambda_function = lambda_.Function(self, "MyFunction",
runtime=lambda_.Runtime.NODEJS_22_X,
handler="index.handler",
code=lambda_.Code.from_inline("""
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello from Lambda!' })
};
};
""")
)
# Create a gateway target with Lambda and tool schema
target = agentcore.GatewayTarget.for_lambda(self, "MyLambdaTarget",
gateway_target_name="my-lambda-target",
description="Target for Lambda function integration",
gateway=gateway,
lambda_function=lambda_function,
tool_schema=agentcore.ToolSchema.from_local_asset(
path.join(__dirname, "schemas", "my-tool-schema.json"))
)
Gateway gateway = Gateway.Builder.create(this, "MyGateway")
.gatewayName("my-gateway")
.build();
Function lambdaFunction = Function.Builder.create(this, "MyFunction")
.runtime(Runtime.NODEJS_22_X)
.handler("index.handler")
.code(Code.fromInline("\n exports.handler = async (event) => {\n return {\n statusCode: 200,\n body: JSON.stringify({ message: 'Hello from Lambda!' })\n };\n };\n "))
.build();
// Create a gateway target with Lambda and tool schema
GatewayTarget target = GatewayTarget.forLambda(this, "MyLambdaTarget", GatewayTargetLambdaProps.builder()
.gatewayTargetName("my-lambda-target")
.description("Target for Lambda function integration")
.gateway(gateway)
.lambdaFunction(lambdaFunction)
.toolSchema(ToolSchema.fromLocalAsset(path.join(__dirname, "schemas", "my-tool-schema.json")))
.build());
// Install: dotnet add package Amazon.CDK.Lib
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
GatewayName = "my-gateway"
});
var lambdaFunction = new Function(this, "MyFunction", new FunctionProps {
Runtime = Runtime.NODEJS_22_X,
Handler = "index.handler",
Code = Code.FromInline(@"
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello from Lambda!' })
};
};
")
});
// Create a gateway target with Lambda and tool schema
var target = GatewayTarget.ForLambda(this, "MyLambdaTarget", new GatewayTargetLambdaProps {
GatewayTargetName = "my-lambda-target",
Description = "Target for Lambda function integration",
Gateway = gateway,
LambdaFunction = lambdaFunction,
ToolSchema = ToolSchema.FromLocalAsset(path.Join(__dirname, "schemas", "my-tool-schema.json"))
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
gateway := agentcore.NewGateway(this, jsii.String("MyGateway"), &GatewayProps{
GatewayName: jsii.String("my-gateway"),
})
lambdaFunction := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
Runtime: lambda.Runtime_NODEJS_22_X(),
Handler: jsii.String("index.handler"),
Code: lambda.Code_FromInline(jsii.String(`
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello from Lambda!' })
};
};
`)),
})
// Create a gateway target with Lambda and tool schema
target := agentcore.GatewayTarget_ForLambda(this, jsii.String("MyLambdaTarget"), &GatewayTargetLambdaProps{
GatewayTargetName: jsii.String("my-lambda-target"),
Description: jsii.String("Target for Lambda function integration"),
Gateway: gateway,
LambdaFunction: lambdaFunction,
ToolSchema: agentcore.ToolSchema_FromLocalAsset(path.join(__dirname, jsii.String("schemas"), jsii.String("my-tool-schema.json"))),
})
Properties
authorizerConfigurationoptionalIGatewayAuthorizerConfigauthorizer_configurationoptionalIGatewayAuthorizerConfigauthorizerConfigurationoptionalIGatewayAuthorizerConfigAuthorizerConfigurationoptionalIGatewayAuthorizerConfigAuthorizerConfigurationoptionalIGatewayAuthorizerConfig #Default: A default authorizer will be created using Cognito
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #Default: No description
exceptionLeveloptionalGatewayExceptionLevelexception_leveloptionalGatewayExceptionLevelexceptionLeveloptionalGatewayExceptionLevelExceptionLeveloptionalGatewayExceptionLevelExceptionLeveloptionalGatewayExceptionLevel #Default: Exception messages are sanitized for presentation to end users
gatewayNameoptionalstringgateway_nameoptionalstrgatewayNameoptionalStringGatewayNameoptionalstringGatewayNameoptional*string #Default: auto generate
interceptorConfigurationsoptionalIInterceptor[]interceptor_configurationsoptionaltyping.List[IInterceptor]interceptorConfigurationsoptionalList<IInterceptor>InterceptorConfigurationsoptionalIInterceptor[]InterceptorConfigurationsoptional*[]IInterceptor #Default: No interceptors
notes
Interceptors allow you to run custom code during each gateway invocation:
- REQUEST interceptors execute before the gateway calls the target
- RESPONSE interceptors execute after the target responds
A gateway can have at most one REQUEST interceptor and one RESPONSE interceptor.
Default: No encryption
policyEngineConfigurationoptionalGatewayPolicyEngineConfigpolicy_engine_configurationoptionalGatewayPolicyEngineConfigpolicyEngineConfigurationoptionalGatewayPolicyEngineConfigPolicyEngineConfigurationoptionalGatewayPolicyEngineConfigPolicyEngineConfigurationoptionalGatewayPolicyEngineConfig #Default: No policy engine (requests are not subject to Cedar policy authorization)
When provided, the specified policy engine will be associated with this gateway. All agent requests through this gateway will be evaluated against the Cedar policies defined in the policy engine.
protocolConfigurationoptionalIGatewayProtocolConfigprotocol_configurationoptionalIGatewayProtocolConfigprotocolConfigurationoptionalIGatewayProtocolConfigProtocolConfigurationoptionalIGatewayProtocolConfigProtocolConfigurationoptionalIGatewayProtocolConfig #Default: A default protocol configuration will be created using MCP with following params supportedVersions: [MCPProtocolVersion.MCP_2025_03_26], searchType: McpGatewaySearchType.SEMANTIC, instructions: "Default gateway to connect to external MCP tools",
Default: A new role will be created
tagsoptional{ [key: string]: string }tagsoptionaltyping.Mapping[str, str]tagsoptionalMap<String, String>TagsoptionalIDictionary<string, string>Tagsoptional*map[string]*string #Default: No tags