Resource: awsRouteTableAssociation
Provides a resource to create an association between a route table and a subnet or a route table and an internet gateway or virtual private gateway.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.routeTableAssociation.RouteTableAssociation(this, "a", {
routeTableId: "${aws_route_table.bar.id}",
subnetId: "${aws_subnet.foo.id}",
});
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.routeTableAssociation.RouteTableAssociation(this, "b", {
gatewayId: "${aws_internet_gateway.foo.id}",
routeTableId: "${aws_route_table.bar.id}",
});
Argument Reference
\~> NOTE: Please note that one of either subnetId
or gatewayId
is required.
The following arguments are supported:
subnetId
- (Optional) The subnet ID to create an association. Conflicts withgatewayId
.gatewayId
- (Optional) The gateway ID to create an association. Conflicts withsubnetId
.routeTableId
- (Required) The ID of the routing table to associate with.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
id
- The ID of the association
Import
\~> NOTE: Attempting to associate a route table with a subnet or gateway, where either is already associated, will result in an error (e.g., resourceAlreadyAssociated:TheSpecifiedAssociationForRouteTable rtb4176657279ConflictsWithAnExistingAssociation
) unless you first import the original association.
EC2 Route Table Associations can be imported using the associated resource ID and Route Table ID separated by a forward slash (/
).
For example with EC2 Subnets:
For example with EC2 Internet Gateways: