Class GatewayTarget
Defines tools that your gateway will host.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.BedrockAgentCore
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class GatewayTarget : GatewayTargetBase, IMcpGatewayTarget, IGatewayTarget, IResource, IGatewayTargetRef, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class GatewayTarget Inherits GatewayTargetBase Implements IMcpGatewayTarget, IGatewayTarget, IResource, IGatewayTargetRef, IConstruct, IDependable, IEnvironmentAware
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
Examples
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"))
});
Synopsis
Constructors
| GatewayTarget(Construct, string, IGatewayTargetProps) | Defines tools that your gateway will host. |
Properties
| CreatedAt | Timestamp when the gateway target was created. |
| CredentialProviderConfigurations | The credential providers for this target. |
| Description | Optional description for the gateway target. |
| Gateway | The gateway this target belongs to. |
| GatewayTargetName | The name of the gateway target. |
| PROPERTY_INJECTION_ID | Uniquely identifies this class. |
| Status | The status of the gateway target. |
| StatusReasons | The status reasons for the gateway target. |
| TargetArn | The ARN of the gateway target. |
| TargetId | The unique identifier of the gateway target. |
| TargetProtocolType | The protocol type (always MCP for now). |
| TargetType | The specific MCP target type (Lambda, OpenAPI, Smithy, or MCP Server). |
| UpdatedAt | Timestamp when the gateway target was last updated. |
Methods
| ForApiGateway(Construct, string, IGatewayTargetApiGatewayProps) | Create an API Gateway-based target Convenience method for creating a target that connects to an API Gateway REST API. |
| ForLambda(Construct, string, IGatewayTargetLambdaProps) | Create a Lambda-based MCP target Convenience method for creating a target that wraps a Lambda function. |
| ForMcpServer(Construct, string, IGatewayTargetMcpServerProps) | Create an MCP Server-based target Convenience method for creating a target that connects to an external MCP server. |
| ForOpenApi(Construct, string, IGatewayTargetOpenApiProps) | Create an OpenAPI-based MCP target Convenience method for creating a target that exposes an OpenAPI/REST API. |
| ForSmithy(Construct, string, IGatewayTargetSmithyProps) | Create a Smithy-based MCP target Convenience method for creating a target that exposes a Smithy-modeled API. |
| FromGatewayTargetAttributes(Construct, string, IGatewayTargetAttributes) | Import an existing Gateway Target using its attributes This allows you to reference a Gateway Target that was created outside of CDK. |
| GrantSync(IGrantable) | Grants permission to synchronize this gateway's targets. |
Constructors
GatewayTarget(Construct, string, IGatewayTargetProps)
Defines tools that your gateway will host.
public GatewayTarget(Construct scope, string id, IGatewayTargetProps props)
Parameters
- scope Construct
- id string
- props IGatewayTargetProps
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
Examples
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"))
});
Properties
CreatedAt
Timestamp when the gateway target was created.
public override string? CreatedAt { get; }
Property Value
Overrides
Remarks
Attribute: true
CredentialProviderConfigurations
The credential providers for this target.
public override ICredentialProviderConfig[]? CredentialProviderConfigurations { get; }
Property Value
Overrides
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
Description
Optional description for the gateway target.
public override string? Description { get; }
Property Value
Overrides
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
Gateway
The gateway this target belongs to.
public override IGateway Gateway { get; }
Property Value
Overrides
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
GatewayTargetName
The name of the gateway target.
public override string GatewayTargetName { get; }
Property Value
Overrides
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
Status
The status of the gateway target.
public override string? Status { get; }
Property Value
Overrides
Remarks
Attribute: true
StatusReasons
The status reasons for the gateway target.
public override string[]? StatusReasons { get; }
Property Value
string[]
Overrides
Remarks
Attribute: true
TargetArn
The ARN of the gateway target.
public override string TargetArn { get; }
Property Value
Overrides
Remarks
Attribute: true
TargetId
The unique identifier of the gateway target.
public override string TargetId { get; }
Property Value
Overrides
Remarks
Attribute: true
TargetProtocolType
The protocol type (always MCP for now).
public override GatewayTargetProtocolType TargetProtocolType { get; }
Property Value
Overrides
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
TargetType
The specific MCP target type (Lambda, OpenAPI, Smithy, or MCP Server).
public virtual McpTargetType TargetType { get; }
Property Value
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
UpdatedAt
Timestamp when the gateway target was last updated.
public override string? UpdatedAt { get; }
Property Value
Overrides
Remarks
Attribute: true
Methods
ForApiGateway(Construct, string, IGatewayTargetApiGatewayProps)
Create an API Gateway-based target Convenience method for creating a target that connects to an API Gateway REST API.
public static GatewayTarget ForApiGateway(Construct scope, string id, IGatewayTargetApiGatewayProps props)
Parameters
- scope Construct
The construct scope.
- id string
The construct id.
- props IGatewayTargetApiGatewayProps
The properties for the API Gateway target.
Returns
A new GatewayTarget instance
Remarks
ForLambda(Construct, string, IGatewayTargetLambdaProps)
Create a Lambda-based MCP target Convenience method for creating a target that wraps a Lambda function.
public static GatewayTarget ForLambda(Construct scope, string id, IGatewayTargetLambdaProps props)
Parameters
- scope Construct
The construct scope.
- id string
The construct id.
- props IGatewayTargetLambdaProps
The properties for the Lambda target.
Returns
A new GatewayTarget instance
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
ForMcpServer(Construct, string, IGatewayTargetMcpServerProps)
Create an MCP Server-based target Convenience method for creating a target that connects to an external MCP server.
public static GatewayTarget ForMcpServer(Construct scope, string id, IGatewayTargetMcpServerProps props)
Parameters
- scope Construct
The construct scope.
- id string
The construct id.
- props IGatewayTargetMcpServerProps
The properties for the MCP server target.
Returns
A new GatewayTarget instance
Remarks
ForOpenApi(Construct, string, IGatewayTargetOpenApiProps)
Create an OpenAPI-based MCP target Convenience method for creating a target that exposes an OpenAPI/REST API.
public static GatewayTarget ForOpenApi(Construct scope, string id, IGatewayTargetOpenApiProps props)
Parameters
- scope Construct
The construct scope.
- id string
The construct id.
- props IGatewayTargetOpenApiProps
The properties for the OpenAPI target.
Returns
A new GatewayTarget instance
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
ForSmithy(Construct, string, IGatewayTargetSmithyProps)
Create a Smithy-based MCP target Convenience method for creating a target that exposes a Smithy-modeled API.
public static GatewayTarget ForSmithy(Construct scope, string id, IGatewayTargetSmithyProps props)
Parameters
- scope Construct
The construct scope.
- id string
The construct id.
- props IGatewayTargetSmithyProps
The properties for the Smithy target.
Returns
A new GatewayTarget instance
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
FromGatewayTargetAttributes(Construct, string, IGatewayTargetAttributes)
Import an existing Gateway Target using its attributes This allows you to reference a Gateway Target that was created outside of CDK.
public static IGatewayTarget FromGatewayTargetAttributes(Construct scope, string id, IGatewayTargetAttributes attrs)
Parameters
- scope Construct
The construct scope.
- id string
The construct id.
- attrs IGatewayTargetAttributes
The attributes of the existing Gateway Target.
Returns
An IGatewayTarget instance representing the imported target
Remarks
Supports multiple target types:
Resource: AWS::BedrockAgentCore::GatewayTarget
ExampleMetadata: fixture=default infused
GrantSync(IGrantable)
Grants permission to synchronize this gateway's targets.
public virtual Grant GrantSync(IGrantable grantee)
Parameters
- grantee IGrantable
Returns
Remarks
This method grants the SynchronizeGatewayTargets permission, which is primarily
needed for MCP Server targets when you need to refresh the tool catalog after the
MCP server's tools have changed.
[disable-awslint:no-grants]