awscc_ec2_subnet_route_table_association (Resource)

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.

Example Usage

Basic usage - associate custom route table with subnet in VPC

resource "awscc_ec2_subnet_route_table_association" "this" {
  route_table_id = awscc_ec2_route_table.this.id
  subnet_id      = awscc_ec2_subnet.this.id
}

resource "awscc_ec2_vpc" "this" {
  cidr_block = "10.0.0.0/16"
  tags = [{
    key   = "Managed By"
    value = "AWSCC"
  }]
}

resource "awscc_ec2_route_table" "this" {
  vpc_id = awscc_ec2_vpc.this.id
  tags = [{
    key   = "Managed By"
    value = "AWSCC"
  }]
}

resource "awscc_ec2_subnet" "this" {
  vpc_id            = awscc_ec2_vpc.this.id
  cidr_block        = "10.0.101.0/24"
  availability_zone = "us-east-1a"
  tags = [{
    key   = "Managed By"
    value = "AWSCC"
  }]
}

Schema

Required

Read-Only

Import

Import is supported using the following syntax:

$ terraform import awscc_ec2_subnet_route_table_association.example <resource ID>