###############################################################################
# You will need to customize the route blocks below to align with your existing 
# route table. If you use Terraform aws_route resources you would remove the
# route blocks altogether.
#
# IMPORT STATEMENT
#
# terraform import aws_route_table.tgw_utility V1_ROUTE_TABLE_ID
###############################################################################
resource "aws_route_table" "v2_route_table_V1_ROUTE_TABLE_NAME" {
  vpc_id = var.vpc_id

  route {
    cidr_block ="10.0.0.0/8"
    transit_gateway_id = data.aws_ec2_transit_gateway_vpc_attachment.tgw.transit_gateway_id
  }

  # Generally, this route would be included only for private route tables.
  route {
    cidr_block ="128.84.0.0/16"
    transit_gateway_id = data.aws_ec2_transit_gateway_vpc_attachment.tgw.transit_gateway_id
  }

  # Generally, this route would be included only for private route tables.
  route {
    cidr_block ="128.253.0.0/16"
    transit_gateway_id = data.aws_ec2_transit_gateway_vpc_attachment.tgw.transit_gateway_id
  }

  # Generally, this route would be included only for private route tables.
  route {
    cidr_block ="132.236.0.0/16"
    transit_gateway_id = data.aws_ec2_transit_gateway_vpc_attachment.tgw.transit_gateway_id
  }

  # Generally, this route would be included only for private route tables.
  route {
    cidr_block ="192.35.82.0/24"
    transit_gateway_id = data.aws_ec2_transit_gateway_vpc_attachment.tgw.transit_gateway_id
  }

  # Generally, this route would be included only for private route tables.
  route {
    cidr_block ="192.122.235.0/24"
    transit_gateway_id = data.aws_ec2_transit_gateway_vpc_attachment.tgw.transit_gateway_id
  }

  # Generally, this route would be included only for private route tables.
  route {
    cidr_block ="192.122.236.0/24"
    transit_gateway_id = data.aws_ec2_transit_gateway_vpc_attachment.tgw.transit_gateway_id
  }

  tags = {
    Name = "V1_ROUTE_TABLE_NAME-rt-dc-arch-v2"
    "cit:contact-email" = "cloud-support@cornell.edu"
    "cit:dc-arch-migration-new-resource" = "yes"
    "cit:dc-arch-migration-description" = "This Route Table will replace V1_ROUTE_TABLE_NAME (V1_ROUTE_TABLE_ID) in the version 2 Direct Connect architecture."
    "cit:dc-arch-migration-replaces" = "V1_ROUTE_TABLE_ID"
    "cit:dc-arch-migration-target" = "yes"
    "cit:dc-arch-version" = "v2"
    "cit:documentation" = "https://confluence.cornell.edu/x/vKr2Gg"
    "cit:source" ="https://github.com/CU-CommunityApps/ct-aws-tgw/"
  }
}

###############################################################################
# You will also need to create Terraform configuration to assign each 
# subnet and v2 Route Table 
#
# IMPORT STATEMENT
#
# terraform import aws_route_table_association.TBD SUBNET_ID/ROUTE_TABLE_ID
###############################################################################
resource "aws_route_table_association" "TBD" {
  subnet_id      = TBD
  route_table_id = TBD
}
