# GatewayTarget

Defines tools that your gateway will host.

Supports multiple target types:
- Lambda: Wraps a Lambda function as MCP tools
- OpenAPI: Exposes an OpenAPI/REST API as MCP tools
- Smithy: Exposes a Smithy-modeled API as MCP tools

Extends: Construct › Resource › GatewayTargetBase › GatewayTarget
Implements: IResource, IGatewayTarget, IMcpGatewayTarget, IEnvironmentAware, IGatewayTargetRef, IConstruct, IDependable

- CloudFormation: [`AWS::BedrockAgentCore::GatewayTarget`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-bedrockagentcore-gatewaytarget.html)
- L1 type: [`CfnGatewayTarget`](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.CfnGatewayTarget.html)
- Source: [`aws-bedrockagentcore/lib/gateway/targets/target.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/gateway/targets/target.ts#L278)
- Type last changed: v2.255.0 · 19 May 2026

## 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")
  ),
});
```

## Initializer

```ts
new GatewayTarget(scope: Construct, id: string, props: GatewayTargetProps)
```

## Construct Props

- `credentialProviderConfigurations`: [ICredentialProviderConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.ICredentialProviderConfig.html)[] — Credential providers for authentication.

  **Default:** [GatewayCredentialProvider.fromIamRole()]

- `description`: string — Optional description for the gateway target The description can have up to 200 characters.

  **Default:** No description

- `gateway`: [IGateway](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.IGateway.html) (required) — The gateway this target belongs to.

- `gatewayTargetName`: string — The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$.

  **Default:** auto generate

- `targetConfiguration`: [ITargetConfiguration](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.ITargetConfiguration.html) (required) — The target configuration (Lambda, OpenAPI, or Smithy) Use one of the configuration helper classes: - LambdaTargetConfiguration.create() - OpenApiTargetConfiguration.create() - SmithyTargetConfiguration.create().

## Properties

- `createdAt`: string — Timestamp when the gateway target was created.

- `credentialProviderConfigurations`: [ICredentialProviderConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.ICredentialProviderConfig.html)[] — The credential providers for this target.

- `description`: string — Optional description for the gateway target.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `gateway`: [IGateway](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.IGateway.html) (required) — The gateway this target belongs to.

- `gatewayTargetName`: string (required) — The name of the gateway target.

- `gatewayTargetRef`: [GatewayTargetReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_bedrockagentcore.GatewayTargetReference.html) (required) — A reference to a GatewayTarget resource.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `PROPERTY_INJECTION_ID`: string (required) (static) — Uniquely identifies this class.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

- `status`: string — The status of the gateway target.

- `statusReasons`: string[] — The status reasons for the gateway target.

- `targetArn`: string (required) — The ARN of the gateway target.

- `targetId`: string (required) — The unique identifier of the gateway target.

- `targetProtocolType`: [GatewayTargetProtocolType](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.GatewayTargetProtocolType.html) (required) — The protocol type (always MCP for now).

- `targetType`: [McpTargetType](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.McpTargetType.html) (required) — The specific MCP target type (Lambda, OpenAPI, Smithy, or MCP Server).

- `updatedAt`: string — Timestamp when the gateway target was last updated.

## Methods

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `forApiGateway(scope: Construct, id: string, props: GatewayTargetApiGatewayProps): GatewayTarget // chainable` (static) — Create an API Gateway-based target Convenience method for creating a target that connects to an API Gateway REST API.

  **Parameters**

  - `scope` — The construct scope.
  - `id` — The construct id.
  - `props` — The properties for the API Gateway target.

  **Returns:** A new GatewayTarget instance

- `forLambda(scope: Construct, id: string, props: GatewayTargetLambdaProps): GatewayTarget // chainable` (static) — Create a Lambda-based MCP target Convenience method for creating a target that wraps a Lambda function.

  **Parameters**

  - `scope` — The construct scope.
  - `id` — The construct id.
  - `props` — The properties for the Lambda target.

  **Returns:** A new GatewayTarget instance

- `forMcpServer(scope: Construct, id: string, props: GatewayTargetMcpServerProps): GatewayTarget // chainable` (static) — Create an MCP Server-based target Convenience method for creating a target that connects to an external MCP server.

  **Parameters**

  - `scope` — The construct scope.
  - `id` — The construct id.
  - `props` — The properties for the MCP server target.

  **Returns:** A new GatewayTarget instance

- `forOpenApi(scope: Construct, id: string, props: GatewayTargetOpenApiProps): GatewayTarget // chainable` (static) — Create an OpenAPI-based MCP target Convenience method for creating a target that exposes an OpenAPI/REST API.

  **Parameters**

  - `scope` — The construct scope.
  - `id` — The construct id.
  - `props` — The properties for the OpenAPI target.

  **Returns:** A new GatewayTarget instance

- `forSmithy(scope: Construct, id: string, props: GatewayTargetSmithyProps): GatewayTarget // chainable` (static) — Create a Smithy-based MCP target Convenience method for creating a target that exposes a Smithy-modeled API.

  **Parameters**

  - `scope` — The construct scope.
  - `id` — The construct id.
  - `props` — The properties for the Smithy target.

  **Returns:** A new GatewayTarget instance

- `fromGatewayTargetAttributes(scope: Construct, id: string, attrs: GatewayTargetAttributes): IGatewayTarget` (static) — Import an existing Gateway Target using its attributes This allows you to reference a Gateway Target that was created outside of CDK.

  **Parameters**

  - `scope` — The construct scope.
  - `id` — The construct id.
  - `attrs` — The attributes of the existing Gateway Target.

  **Returns:** An IGatewayTarget instance representing the imported target

- `grant(grantee: IGrantable, ...actions: string[]): Grant` — Grants IAM actions to the IAM Principal.

  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — The principal to grant permissions to.
  - `actions` — The IAM actions to grant.

- `grantManage(grantee: IGrantable): Grant` — Grants `Create`, `Update`, and `Delete` actions on the Gateway Target.

  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — The principal to grant manage permissions to.

- `grantRead(grantee: IGrantable): Grant` — Grants `Get` and `List` actions on the Gateway Target.

  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — The principal to grant read permissions to.

- `grantSync(grantee: IGrantable): Grant` — Grants permission to synchronize this gateway's targets.

  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]

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
