terraform apply keeps changing things even though no tf files have changed
terraform apply keeps changing things even though no tf files have changed
I have a moderately complex terraform setup with
a module directory containing a main.tf, variables.tf and input.tf
and environments directory containing foo.tf, variables.tf and vars.tf
I can successfully run terraform apply and everything succeeds.
But, if I immediately run terraform apply again it makes changes.
The changes it keeps making are to resources in the module...resources that get attributes from variables in the environments tf files. I'm creating an MQ broker and a dashboard to monitor it.
In the environments directory
top.tf
module "broker"
source = "modules/broker"
dashboard = "...."
In the modules directory
input.tf
variable "dashboard"
amazonmq.tf
resource "aws_cloudwatch_dashboard" "mydash"
dashboard_name = "foo"
dashboard_body = "$dashboard"
Every time I run terraform apply it says it needs to change the dashboard. Any hints on what I'm doing wrong? (I've tried running with TF_LOG=DEBUG but I can't see anything that says why a change is needed). Thanks in advance.
I'd venture to say that your JSON file for the dashboard is being reformatted or reorganized by AWS, and when you run apply - you're trying to do it with your version again. I've run into this with ECS Task Definitions before, where AWS would re-order my environment variables, so I would have to change my definition to match however they ordered them.
– TJ Biddle
Aug 29 at 11:59
1 Answer
1
This seems to be an issue with the terraform provider code itself. The dashboard_body property should have the computed flag attached to it, to allow you to provide it but ignore any incoming changes from aws.
I've opened up an issue on the github page. You'll find it here: https://github.com/terraform-providers/terraform-provider-aws/issues/5729
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Any chance you can work on making your example code an Minimal, Complete, and Verifiable example so we can reproduce your issue? As is your example code doesn't work at all and I doubt even fixing it would show the same issue you are seeing which makes this impossible for anyone to help you with.
– ydaetskcoR
Aug 29 at 8:35