Skip to content

Commit

Permalink
change peer, self
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Oct 20, 2022
1 parent 975d3ad commit 71ae049
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions vpc-transit-gateway-association/peer/associate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ locals {
# add routes to peer for non-services
#---
resource "aws_ec2_transit_gateway_route" "vpc_peer_own_rt" {
provider = aws.peer
# provider = aws.peer
provider = aws
for_each = { for k in local.selected_rt : k => local.transit_gateway_route_table_ids_peer[k] if k == var.transit_gateway_environment }
destination_cidr_block = data.aws_vpc.vpc.cidr_block

Expand All @@ -22,7 +23,8 @@ resource "aws_ec2_transit_gateway_route" "vpc_peer_own_rt" {
# always add routes to services
#--
resource "aws_ec2_transit_gateway_route" "vpc_peer_common" {
provider = aws.peer
# provider = aws.peer
provider = aws
for_each = { "services" = local.transit_gateway_route_table_ids_peer["services"] }
destination_cidr_block = data.aws_vpc.vpc.cidr_block

Expand All @@ -34,7 +36,8 @@ resource "aws_ec2_transit_gateway_route" "vpc_peer_common" {
# if services, add routes to all other route tables
#--
resource "aws_ec2_transit_gateway_route" "vpc_peer_all" {
provider = aws.peer
# provider = aws.peer
provider = aws
for_each = contains(local.propagate_all_rt, var.transit_gateway_environment) ? { for k in local.selected_rt : k => local.transit_gateway_route_table_ids_peer[k] } : {}
destination_cidr_block = data.aws_vpc.vpc.cidr_block

Expand Down
10 changes: 7 additions & 3 deletions vpc-transit-gateway-association/self/associate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# attach this vpc to tgw (my region, my account)
#---
resource "aws_ec2_transit_gateway_vpc_attachment" "vpc_attachment" {
provider = aws
# subnet_ids = [for sn in module.subnets.private_subnets_ids : sn.id if lookup(sn.tags, "boc:vpc:route-table", null) == "attachment"]
subnet_ids = [for k, v in var.private_subnets_ids : v.id]
transit_gateway_id = data.aws_ec2_transit_gateway.gateway_self.id
Expand All @@ -24,7 +25,8 @@ resource "aws_ec2_transit_gateway_vpc_attachment" "vpc_attachment" {
# assocaite this vpc to route table in self (my region, network account)
#---
resource "aws_ec2_transit_gateway_route_table_association" "route_table_self" {
provider = aws.self
provider = aws
# provider = aws.self
transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.vpc_attachment.id
transit_gateway_route_table_id = local.transit_gateway_route_table_ids_self[var.transit_gateway_environment]
}
Expand All @@ -44,7 +46,8 @@ locals {
# we will cover services and inter-region separately
#---
resource "aws_ec2_transit_gateway_route_table_propagation" "vpc_self_own_rt" {
provider = aws.self
provider = aws
# provider = aws.self
for_each = { for k in local.selected_rt : k => local.transit_gateway_route_table_ids_self[k] }

transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.vpc_attachment.id
Expand All @@ -56,7 +59,8 @@ resource "aws_ec2_transit_gateway_route_table_propagation" "vpc_self_own_rt" {
# propagate all to inter-region table
#---
resource "aws_ec2_transit_gateway_route_table_propagation" "vpc_self_common" {
provider = aws.self
# provider = aws.self
provider = aws
for_each = { for k in local.propagate_all_rt : k => local.transit_gateway_route_table_ids_self[k] }

transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.vpc_attachment.id
Expand Down

0 comments on commit 71ae049

Please sign in to comment.