resource "aws_ec2_transit_gateway" "example" {
  description = "example"
  auto_accept_shared_attachments = "enable"
  default_route_table_association = "enable"
  dns_support = "enable"
  multicast_support = "enable"
  vpn_ecmp_support = "enable"
  tags = {
    Name = "wsc2024-vpc-tgw"
  }
}

resource "aws_ec2_transit_gateway_vpc_attachment" "ma" {
  subnet_ids         = [aws_subnet.public_a.id]
  transit_gateway_id = aws_ec2_transit_gateway.example.id
  vpc_id             = aws_vpc.ma.id
  tags = {
    Name = "wsc2024-ma-tgw-attache"
  }
}

resource "aws_ec2_transit_gateway_vpc_attachment" "prod" {
  subnet_ids         = [aws_subnet.prod_a.id, aws_subnet.prod_b.id]
  transit_gateway_id = aws_ec2_transit_gateway.example.id
  vpc_id             = aws_vpc.prod.id
  tags = {
    Name = "wsc2024-prod-tgw-attache"
  }
}

resource "aws_ec2_transit_gateway_vpc_attachment" "storage" {
  subnet_ids         = [aws_subnet.storage_a.id,aws_subnet.storage_b.id]
  transit_gateway_id = aws_ec2_transit_gateway.example.id
  vpc_id             = aws_vpc.storage.id
  tags = {
    Name = "wsc2024-storage-tgw-attache"
  }
}

resource "aws_ec2_transit_gateway_route_table" "customer" {
  transit_gateway_id = aws_ec2_transit_gateway.example.id
  tags = {
    Name = "wsc2024-ma-tgw-rt"
  }
}
resource "aws_ec2_transit_gateway_route_table" "prod" {
  transit_gateway_id = aws_ec2_transit_gateway.example.id
  tags = {
    Name = "wsc2024-prod-tgw-rt"
  }
}
resource "aws_ec2_transit_gateway_route_table" "order" {
  transit_gateway_id = aws_ec2_transit_gateway.example.id
  tags = {
    Name = "wsc2024-storage-tgw-rt"
  }
}