Skip to content

Resource: awsMainRouteTableAssociation

Provides a resource for managing the main routing table of a VPC.

\~> NOTE: Do not use both awsDefaultRouteTable to manage a default route table and awsMainRouteTableAssociation with the same VPC due to possible route conflicts. See aws_default_route_table documentation for more details. For more information, see the Amazon VPC User Guide on Route Tables. For information about managing normal route tables in Terraform, see awsRouteTable.

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.mainRouteTableAssociation.MainRouteTableAssociation(this, "a", {
  routeTableId: "${aws_route_table.bar.id}",
  vpcId: "${aws_vpc.foo.id}",
});

Argument Reference

The following arguments are supported:

  • vpcId - (Required) The ID of the VPC whose main route table should be set
  • routeTableId - (Required) The ID of the Route Table to set as the new main route table for the target VPC

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The ID of the Route Table Association
  • originalRouteTableId - Used internally, see Notes below

Notes

On VPC creation, the AWS API always creates an initial Main Route Table. This resource records the ID of that Route Table under originalRouteTableId. The "Delete" action for a mainRouteTableAssociation consists of resetting this original table as the Main Route Table for the VPC. You'll see this additional Route Table in the AWS console; it must remain intact in order for the mainRouteTableAssociation delete to work properly.