github.com/SUSE/skuba@v1.4.17/ci/infra/aws/vpc_peering_connection.tf (about) 1 resource "aws_vpc_peering_connection" "tunnel" { 2 count = length(var.peer_vpc_ids) 3 peer_vpc_id = var.peer_vpc_ids[count.index] 4 vpc_id = aws_vpc.platform.id 5 auto_accept = true 6 tags = merge( 7 local.tags, 8 { 9 "Class" = "VPC-peering-connection" 10 }, 11 ) 12 13 accepter { 14 allow_remote_vpc_dns_resolution = true 15 } 16 17 requester { 18 allow_remote_vpc_dns_resolution = true 19 } 20 } 21 22 data "aws_vpc" "peer" { 23 count = length(var.peer_vpc_ids) 24 id = var.peer_vpc_ids[count.index] 25 } 26 27 resource "aws_route" "peer_to_k8s" { 28 count = length(var.peer_vpc_ids) 29 route_table_id = element(data.aws_vpc.peer.*.main_route_table_id, count.index) 30 destination_cidr_block = aws_vpc.platform.cidr_block 31 vpc_peering_connection_id = element(aws_vpc_peering_connection.tunnel.*.id, count.index) 32 } 33 34 resource "aws_route" "public_subnet_to_peer" { 35 count = length(var.peer_vpc_ids) 36 route_table_id = aws_route_table.public.id 37 destination_cidr_block = element(data.aws_vpc.peer.*.cidr_block, count.index) 38 vpc_peering_connection_id = element(aws_vpc_peering_connection.tunnel.*.id, count.index) 39 } 40 41 resource "aws_route" "private_subnet_to_peer" { 42 count = length(var.peer_vpc_ids) 43 route_table_id = aws_route_table.private.id 44 destination_cidr_block = element(data.aws_vpc.peer.*.cidr_block, count.index) 45 vpc_peering_connection_id = element(aws_vpc_peering_connection.tunnel.*.id, count.index) 46 } 47