- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
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
See CreateTransitGatewayRouteCommandInput for more details
Parameter | Type | Description |
---|
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 |
TransitGatewayAttachmentId | string | undefined | The ID of the attachment. |
CreateTransitGatewayRouteCommand Output
See CreateTransitGatewayRouteCommandOutput for details
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Route | TransitGatewayRoute | undefined | Information about the route. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
EC2ServiceException | Base exception class for all service exceptions from EC2 service. |