Terraform Apply Step Fault Tolerance

Hi,
I currently have a “APPLY A TERRAFORM TEMPLATE” step that runs as part of my workflow and sometimes this step fails for a known reason which appears in the logs of the step. I was wondering if there was any way of running a step after the failed step to check for the specific log in the failed previous step? or is there a way to embed a script within my “APPLY A TERRAFORM TEMPLATE” step to check for the specific error and carryout a retry for example? hope this makes sense.

Hi @mohaned.saad,

Thanks for getting in touch!

The first possibility here would be to enable Guided Failure, and then use the retry option if desired. This is a manual process though and I gather you’re wanting this to be automated.

You can do some of what you suggest by setting the Run Condition within a step to only run when the previous step fails. Your script could try checking the system variable Octopus.Action.Status.Error or Octopus.Action.Status.ErrorDetail to see if that matches the expected error.

The challenge would be how to re-run the failed step though. One option would be to have your script initiate a fresh deployment of the same release to the same environment using the REST API or CLI.

The option you’re likely looking for is one we are currently working on. Which is the ability to retry steps automatically.

Regards,
Paul

1 Like