Skip to content
v2.278.0

GatewayProps Struct ​

Properties for defining a Gateway.

Example ​

ts
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")
  ),
});
python
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"))
)
java
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());
csharp
// 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"))
});
go
// 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 #
The authorizer configuration for the gateway.

Default: A default authorizer will be created using Cognito

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #
Optional description for the gateway Valid characters are a-z, A-Z, 0-9, _ (underscore), - (hyphen) and spaces The description can have up to 200 characters.

Default: No description

exceptionLeveloptionalGatewayExceptionLevelexception_leveloptionalGatewayExceptionLevelexceptionLeveloptionalGatewayExceptionLevelExceptionLeveloptionalGatewayExceptionLevelExceptionLeveloptionalGatewayExceptionLevel #
The verbosity of exception messages Use DEBUG mode to see granular exception messages from a Gateway.

Default: Exception messages are sanitized for presentation to end users

gatewayNameoptionalstringgateway_nameoptionalstrgatewayNameoptionalStringGatewayNameoptionalstringGatewayNameoptional*string #
The name of the gateway Valid characters are a-z, A-Z, 0-9, _ (underscore) and - (hyphen) The name must be unique within your account.

Default: auto generate

interceptorConfigurationsoptionalIInterceptor[]interceptor_configurationsoptionaltyping.List[IInterceptor]interceptorConfigurationsoptionalList<IInterceptor>InterceptorConfigurationsoptionalIInterceptor[]InterceptorConfigurationsoptional*[]IInterceptor #
Interceptor configurations for the gateway.

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.

kmsKeyoptionalIKeykms_keyoptionalIKeykmsKeyoptionalIKeyKmsKeyoptionalIKeyKmsKeyoptionalIKey #
The AWS KMS key used to encrypt data associated with the gateway.

Default: No encryption

policyEngineConfigurationoptionalGatewayPolicyEngineConfigpolicy_engine_configurationoptionalGatewayPolicyEngineConfigpolicyEngineConfigurationoptionalGatewayPolicyEngineConfigPolicyEngineConfigurationoptionalGatewayPolicyEngineConfigPolicyEngineConfigurationoptionalGatewayPolicyEngineConfig #
The policy engine configuration for this gateway.

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 #
The protocol configuration for the gateway.

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",

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole #
The IAM role that provides permissions for the gateway to access AWS services.

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 #
Tags for the gateway A list of key:value pairs of tags to apply to this Gateway resource.

Default: No tags