CreateTransitGatewayRouteCommand

Creates a static route for the specified transit gateway route table.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { EC2Client, CreateTransitGatewayRouteCommand } from "@aws-sdk/client-ec2"; // ES Modules import
// const { EC2Client, CreateTransitGatewayRouteCommand } = require("@aws-sdk/client-ec2"); // CommonJS import
const client = new EC2Client(config);
const input = { // CreateTransitGatewayRouteRequest
  DestinationCidrBlock: "STRING_VALUE", // required
  TransitGatewayRouteTableId: "STRING_VALUE", // required
  TransitGatewayAttachmentId: "STRING_VALUE",
  Blackhole: true || false,
  DryRun: true || false,
};
const command = new CreateTransitGatewayRouteCommand(input);
const response = await client.send(command);
// { // CreateTransitGatewayRouteResult
//   Route: { // TransitGatewayRoute
//     DestinationCidrBlock: "STRING_VALUE",
//     PrefixListId: "STRING_VALUE",
//     TransitGatewayRouteTableAnnouncementId: "STRING_VALUE",
//     TransitGatewayAttachments: [ // TransitGatewayRouteAttachmentList
//       { // TransitGatewayRouteAttachment
//         ResourceId: "STRING_VALUE",
//         TransitGatewayAttachmentId: "STRING_VALUE",
//         ResourceType: "vpc" || "vpn" || "direct-connect-gateway" || "connect" || "peering" || "tgw-peering",
//       },
//     ],
//     Type: "static" || "propagated",
//     State: "pending" || "active" || "blackhole" || "deleting" || "deleted",
//   },
// };

CreateTransitGatewayRouteCommand Input

Parameter
Type
Description
DestinationCidrBlock
Required
string | undefined

The CIDR range used for destination matches. Routing decisions are based on the most specific match.

TransitGatewayRouteTableId
Required
string | undefined

The ID of the transit gateway route table.

Blackhole
boolean | undefined

Indicates whether to drop traffic that matches this route.

DryRun
boolean | undefined

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

TransitGatewayAttachmentId
string | undefined

The ID of the attachment.

CreateTransitGatewayRouteCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
Route
TransitGatewayRoute | undefined

Information about the route.

Throws

Name
Fault
Details
EC2ServiceException
Base exception class for all service exceptions from EC2 service.