Hi,
I have created a module to create AWS routes - please below.
The route table itself was created outside of my TF code and routes can be added manually or even via other TF pipelines (different TF codebases).
The issue is that I have added ‘ignore_changes = all’ to the module so that I can account for routes created by other tools but my TF code errors out when I apply it if routes have been manually added or added by other TF pipelines - when I say error out, I specifically mean that my TF code tries to destroy and re-create the routes previously created by itself.
I know that various tools modifying the same AWS objects is less than ideal but that is the situation I am stuck with.
Any suggestions much appreciated!
My code is as follows:
parent main.tf:
main.tf:
locals {
peering_routes = "${var.peering_routes}"
}
module "peering-routes1" {
source = "./peering-routes"
peering_routes = local.peering_routes
route_table = local.peering_route_tables
default_tags = local.default_tags
}
variable "peering_routes" {
type = list(object({
cidr_block=string
peering_connection=string}))
default = [
{
peering_connection = "pcx--XXXXXXXXXXXXX"
cidr_block = "172.16.0.0/16"
},
{
peering_connection = "pcx-XXXXXXXXXXXXX"
cidr_block = "10.5.0.0/16"
},
{
peering_connection = "pcx-0c77a9efe206c134c"
cidr_block = "10.6.0.0/16"
},
]
}
module main.tf:
resource "aws_route" "peering_routes1" {
count = length(var.peering_routes)
route_table_id = var.route_table[0]
destination_cidr_block = lookup(var.peering_routes[count.index], "cidr_block")
vpc_peering_connection_id = lookup(var.peering_routes[count.index], "peering_connection")
lifecycle {
ignore_changes = all
}
}