'Solving Terraform cycle for seemingly unrelated resources

When I try to apply a terraform configuration I get an error:

Error: Cycle: module.c.google_compute_instance_template.pull (destroy deposed 83fe0757),
module.o.google_compute_instance_template.integration_test,
module.h.google_compute_instance_group_manager.pull (destroy deposed ecd374e7),
module.o.google_compute_instance_template.integration_test (destroy),
module.o.docker_image.service,
module.o.docker_registry_image.service,
module.o.local.image (expand),
module.o.local.cloud_init_content (expand),
module.o.local.cloud_init (expand),
module.o.output.cloud_init (expand),
module.c.var.o (expand),
module.c.var.f (expand),
module.c.local.cloud_init_content (expand),
module.c.google_compute_instance_template.pull,
module.c.output.compute_instance_template (expand),
module.h.var.controller_template (expand),
module.h.google_compute_instance_group_manager.pull,
module.h.google_compute_autoscaler.pull,
module.h.google_compute_autoscaler.pull (destroy deposed 578e3a34),
module.d.google_compute_instance_template.pull (destroy deposed 79860500),
module.c.google_compute_autoscaler.pull,
module.d.local.cloud_init_content (expand),
module.d.google_compute_instance_template.pull,
module.d.output.compute_instance_template (expand),
module.c.var.donkey_instance_template (expand),
module.c.google_compute_instance_group_manager.pull,
module.c.google_compute_instance_group_manager.pull (destroy deposed adf15f71),
module.f.google_compute_instance_template.integration_test,
module.s.google_compute_instance_template.integration_test,
module.s.local.image (expand),
module.s.local.cloud_init_content (expand),
module.s.local.cloud_init (expand),
module.s.output.cloud_init (expand),
module.d.var.s (expand),
module.f.output.cloud_init (expand),
module.d.var.f (expand),
module.d.local.cloud_init_integration_test_content (expand),
module.d.google_compute_instance_template.integration_test,
module.d.google_compute_instance_template.integration_test (destroy deposed c4b1489e),
module.s.google_compute_instance_template.integration_test (destroy),
module.s.docker_image.service,
module.s.docker_registry_image.service,
module.c.google_compute_autoscaler.pull (destroy deposed 45f462e6),
module.f.google_compute_instance_template.integration_test (destroy),
module.f.docker_image.service,
module.f.docker_registry_image.service,
module.f.local.image (expand),
module.f.local.cloud_init_content (expand),
module.f.local.cloud_init (expand)

I cannot really make heads or tails out of it also - e.g. module.c.google_compute_instance_template.pull (destroy deposed 83fe0757) has not dependency on module.o.google_compute_instance_template.integration_test or vice versa. So I am wondering how to read the output and also how to go about fixing it.



Solution 1:[1]

Basically we "solved" this by moving all

lifecycle {
  create_before_destory = true
}

blocks out of the change. It seems like terraform has a hard time figuring out graphs with create_before_destroy combined with other changes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 abergmeier