main.tf 909 B

123456789101112131415161718192021222324252627282930313233
  1. data "aws_availability_zones" "available" {
  2. state = "available"
  3. }
  4. resource "aws_ram_resource_share_accepter" "accept_tgw_share" {
  5. count = var.accept_invitation ? 1 : 0
  6. share_arn = var.share_arn
  7. }
  8. resource "aws_ec2_transit_gateway_vpc_attachment" "attach_tgw" {
  9. depends_on = [aws_ram_resource_share_accepter.accept_tgw_share]
  10. subnet_ids = var.subnets
  11. transit_gateway_id = var.tgw_id
  12. vpc_id = var.vpc_id
  13. tags = merge(
  14. local.standard_tags,
  15. var.tags
  16. )
  17. }
  18. # The VPC automatically tells the TGW about its network, but the
  19. # VPCs themselves need to know what all to send to the TGW. For
  20. # our purposes, it's only RFC1918 addresses. In fact, just
  21. # 10.0.0.0/8 for now.
  22. resource "aws_route" "route_to_10" {
  23. for_each = toset(var.route_tables)
  24. route_table_id = each.value
  25. destination_cidr_block = "10.0.0.0/8"
  26. transit_gateway_id = var.tgw_id
  27. }