Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPC Peering routes should be preserved if they don't change. #33

Open
3h4x opened this issue Apr 19, 2021 · 0 comments
Open

VPC Peering routes should be preserved if they don't change. #33

3h4x opened this issue Apr 19, 2021 · 0 comments

Comments

@3h4x
Copy link

3h4x commented Apr 19, 2021

Describe the Feature

Current code for adding routes is based on count

# Create routes from requestor to acceptor
resource "aws_route" "requestor" {
count = module.this.enabled ? length(distinct(sort(data.aws_route_tables.requestor.0.ids))) * length(data.aws_vpc.acceptor.0.cidr_block_associations) : 0
route_table_id = element(distinct(sort(data.aws_route_tables.requestor.0.ids)), ceil(count.index / length(data.aws_vpc.acceptor.0.cidr_block_associations)))
destination_cidr_block = data.aws_vpc.acceptor.0.cidr_block_associations[count.index % length(data.aws_vpc.acceptor.0.cidr_block_associations)]["cidr_block"]
vpc_peering_connection_id = join("", aws_vpc_peering_connection.default.*.id)
depends_on = [data.aws_route_tables.requestor, aws_vpc_peering_connection.default]
}
# Create routes from acceptor to requestor
resource "aws_route" "acceptor" {
count = module.this.enabled ? length(distinct(sort(data.aws_route_tables.acceptor.0.ids))) * length(data.aws_vpc.requestor.0.cidr_block_associations) : 0
route_table_id = element(distinct(sort(data.aws_route_tables.acceptor.0.ids)), ceil(count.index / length(data.aws_vpc.requestor.0.cidr_block_associations)))
destination_cidr_block = data.aws_vpc.requestor.0.cidr_block_associations[count.index % length(data.aws_vpc.requestor.0.cidr_block_associations)]["cidr_block"]
vpc_peering_connection_id = join("", aws_vpc_peering_connection.default.*.id)
depends_on = [data.aws_route_tables.acceptor, aws_vpc_peering_connection.default]
}

Changing tags can possible result in changing count order and removal of actually using peering routing.

Expected Behavior

If matching pattern tag for a route is changed then only associated route table for this exact peering should be changed.

Use Case

It's possible that downtime will happen during terraform apply when tags will be changed on route.

Describe Ideal Solution

aws_route inside this module should use for_each which would prevent temporary routing changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant