data "aws_availability_zones" "available" { state = "available" } resource "aws_ram_resource_share_accepter" "accept_tgw_share" { count = var.accept_invitation ? 1 : 0 share_arn = var.share_arn } resource "aws_ec2_transit_gateway_vpc_attachment" "attach_tgw" { depends_on = [aws_ram_resource_share_accepter.accept_tgw_share] subnet_ids = var.subnets transit_gateway_id = var.tgw_id vpc_id = var.vpc_id tags = merge( local.standard_tags, var.tags ) } # The VPC automatically tells the TGW about its network, but the # VPCs themselves need to know what all to send to the TGW. For # our purposes, it's only RFC1918 addresses. In fact, just # 10.0.0.0/8 for now. resource "aws_route" "route_to_10" { for_each = toset(var.route_tables) route_table_id = each.value destination_cidr_block = "10.0.0.0/8" transit_gateway_id = var.tgw_id }