class Route (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ec2.Alpha.Route |
Go | github.com/aws/aws-cdk-go/awsec2alpha/v2#Route |
Java | software.amazon.awscdk.services.ec2.alpha.Route |
Python | aws_cdk.aws_ec2_alpha.Route |
TypeScript (source) | @aws-cdk/aws-ec2-alpha ยป Route |
Implements
IConstruct
, IDependable
, IResource
, IRoute
Creates a new route with added functionality.
Example
const myVpc = new VpcV2(this, 'Vpc');
const routeTable = new RouteTable(this, 'RouteTable', {
vpc: myVpc,
});
const subnet = new SubnetV2(this, 'Subnet', {
vpc: myVpc,
availabilityZone: 'eu-west-2a',
ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
subnetType: SubnetType.PRIVATE_ISOLATED });
const natgw = new NatGateway(this, 'NatGW', {
subnet: subnet,
vpc: myVpc,
connectivityType: NatConnectivityType.PRIVATE,
privateIpAddress: '10.0.0.42',
});
new Route(this, 'NatGwRoute', {
routeTable,
destination: '0.0.0.0/0',
target: { gateway: natgw },
});
Initializer
new Route(scope: Construct, id: string, props: RouteProps)
Parameters
- scope
Construct
- id
string
- props
Route
Props
Construct Props
Name | Type | Description |
---|---|---|
destination | string | The IPv4 or IPv6 CIDR block used for the destination match. |
route | IRoute | The ID of the route table for the route. |
target | Route | The gateway or endpoint targeted by the route. |
route | string | The resource name of the route. |
destination
Type:
string
The IPv4 or IPv6 CIDR block used for the destination match.
Routing decisions are based on the most specific match.
routeTable
Type:
IRoute
The ID of the route table for the route.
target
Type:
Route
The gateway or endpoint targeted by the route.
routeName?
Type:
string
(optional, default: provisioned without a route name)
The resource name of the route.
Properties
Name | Type | Description |
---|---|---|
destination | string | The IPv4 or IPv6 CIDR block used for the destination match. |
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
route | IRoute | The route table for the route. |
stack | Stack | The stack in which this resource is defined. |
target | Route | The gateway or endpoint targeted by the route. |
target | Router | The type of router the route is targetting. |
resource? | Cfn | The route CFN resource. |
destination
Type:
string
The IPv4 or IPv6 CIDR block used for the destination match.
Routing decisions are based on the most specific match.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Node
The tree node.
routeTable
Type:
IRoute
The route table for the route.
stack
Type:
Stack
The stack in which this resource is defined.
target
Type:
Route
The gateway or endpoint targeted by the route.
targetRouterType
Type:
Router
The type of router the route is targetting.
resource?
Type:
Cfn
(optional)
The route CFN resource.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
).
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.