AWS Fundamentals Logo
AWS Fundamentals
L1 ConstructAWS::EC2::SubnetRouteTableAssociation

CfnSubnetRouteTableAssociation

Associates a subnet with a route table. The subnet and route table must be in the same VPC. This association causes traffic originating from the subnet to be routed according to the routes in the route table. A route table can be associated with multiple subnets. To create a route table, see [AWS::EC2::RouteTable](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-routetable.html) .

Import

import { CfnSubnetRouteTableAssociation } from 'aws-cdk-lib/aws-ec2';

Or use the module namespace:

import * as ec2 from 'aws-cdk-lib/aws-ec2';
// ec2.CfnSubnetRouteTableAssociation

Properties

Configuration passed to the constructor as CfnSubnetRouteTableAssociationProps.

routeTableIdRequired
string | IRouteTableRef

The ID of the route table. The physical ID changes when the route table ID is changed.

subnetIdRequired
string | ISubnetRef

The ID of the subnet.

CloudFormation Resource

This L1 construct maps directly to the following CloudFormation resource type.

Get the Amazon EC2 Cheat Sheet

Everything you need to know about Amazon EC2 on one page. HD quality, print-friendly.

Download Free Infographic