In my local machine, I tried to use the lifecycle rule (create_before_destroy). After making changes in the configuration file, according to lifecycle, the file is created first, but it gets destroyed too.
I this terraform apply, I have just made the changes in content, but still, the file is not created.
and the old file gets deleted.
Hello @paridua120,
This is an opt-in behavior because many remote object types have unique name requirements or other constraints that must be accommodated for both a new and an old object to exist concurrently. Some resource types offer special options to append a random suffix onto each object name to avoid collisions, for example. Terraform CLI cannot automatically activate such features, so you must understand the constraints for each resource type before using create_before_destroy
with it.
Reference: The lifecycle Meta-Argument - Configuration Language | Terraform | HashiCorp Developer
Thanks,
Trung.
Thank you! Trung, for this valuable information.
1 Like