[Terraform] Terraform destroy -force is deprecated

As a lot of you regular terraform users already know with the official release of Terraform 1.0, the destroy -force has become deprecated. Harness still uses it in the backend, and this may cause you to see an error similar to the below in your UI log trace:

INFO 2021-06-18 15:24:13 connection_string = "redacted"
INFO 2021-06-18 15:24:13 terraform destroy -force
INFO 2021-06-18 15:24:13 ╷
INFO 2021-06-18 15:24:13 │ Error: Failed to parse command-line flags
INFO 2021-06-18 15:24:13 │
INFO 2021-06-18 15:24:13 │ flag provided but not defined: -force

As Harness engineers work to add the support for the latest TF version, we do have a workaround on this which should stop the version from becoming a blocker for most user’s executions.

First add a destroy plan step, then inherit that plan in destroy step like following.

With Terraform deprecating -force flag in versions >= 1.0 , our current execution will fail in destroy steps for this version.

It should work with older versions. Also as terraform does not support it now, we will re analyse effect of this flag in current implementation.

Here are some general screenshots to give an idea of how it is supposed to look.

Using this clears this issue from inheriting the plan from previous step and you can get the desired destroy result in your execution.

Note: This is a temporary workaround and Harness will soon have complete support for Tf version > 1.0