Terraform replace try to create & drop at the same time


I have an issue with terraform apply -replace as it tries to create object before destroy is finished and as a result it fails. Looks like TF treats destroy and create as completely independent as same operation is working fine with sequential execution (parallelism=1)
Is it expected behavior?

Hi @DmitryMaletin,

Terraform always completes one action entirely before the next is started, so if the resource is supposed to be destroyed then created, the two versions cannot exist at the same time within Terraform. If the provider is reporting that the resource is destroyed when in fact it is not, then that would need to be remedied by the provider.

The -parallelism flag should not affect this, since these are serial operations, but it’s possible that the delay imposed by making all other operations serial is just enough for the remote service to catch up.

Please post the the exact Terraform command lines used, the full output from them, and the relevant portions of your Terraform configuration files.

1 Like