Terraform keeps applying the same changes over and over

Hello,

I am adding routes using modules. After every “terraform apply”, it asks to apply the same changes. I click yes, however it asks again after every “terraform plan/apply” to re-apply the same changes.

module “rt_to_tgw” {
source = “…/_modules/route_entries”
rt_id = module.rt_table.route_table_id
destination_cidr = “###.###.###.###/32”
gateway = “tgw_id_here_123456789”
}

I realize the above code is not enough context, pls advise, I can provide more info.

Terraform version? and cloud provider version?

TF v0.12
Cloud Provider is AWS. How can I send you the version?
Thanks.

terraform --version ?

Terraform v0.12.9

  • provider.aws v2.34.0

could you try with the latest Terraform? v0.12.17 as of today and the latest AWS provider.
you could go through the CHANGELOG of each to see if anything specific to your problem was there.

What changes are proposed when you plan?

Sometimes, it can be as silly as parameters listed in the wrong order. I’ve had that happen to me.

Can you include the code of the module you’re importing? I’ve had a similar issue in the past when I combine creating a security group and adding rules within the same resource.

I would suggest never defining rules inline in the aws_security_group resource, instead always use the separate resource aws_security_group_rule for that

1 Like

@bentterp
I should have been more descriptive in saying that was a learning point for me a while back. What I meant was he may be attempting to do something similar and that’s causing his issue. I create all my rules separate from the group.

1 Like

This is the module I’m importing.

resource “aws_route” “main” {
route_table_id = var.rt_id
destination_cidr_block = var.destination_cidr
gateway_id = var.gateway
}

1 Like

Figured it out. I was defining gateway_id instead of using transit_gateway_id

Thank you all for your help and replies.

1 Like