July 6, 2023

New built-in variable adds logic to Custom Hooks

Alistair Heys

As of July 6 2023, Scalr has added a new built-in variable that can be used with Custom Hooks. The SCALR_RUN_IS_DESTROY  variable allows you to incorporate logic into your custom hook scripts, enabling you to differentiate between Terraform apply and Terraform destroy operations effortlessly.

How does it work? By analyzing the return code, you can easily determine the nature of the run. If the return code is 1, it means the run is equivalent to a Terraform destroy. Conversely, a return code of 0 indicates a Terraform apply. This valuable information empowers you to implement intelligent logic in your custom hook scripts, ensuring the right actions are triggered at the right time.

With Custom Hooks and SCALR_RUN_IS_DESTROY, you can automate pre- and post-run processes or customize actions based on specific environments. It's all about having the control to align your workflow with your requirements.

Incorporate Custom Hooks to leverage the power of SCALR_RUN_IS_DESTROY. You can remove manual adjustments by streamlining your personalized workflow that suits your needs.

Sign Up or Sign In to start using Custom Hooks!

Note: While this blog references Terraform, everything mentioned in here also applies to OpenTofu. New to OpenTofu? It is a fork of Terraform 1.5.7 as a result of the license change from MPL to BUSL by HashiCorp. OpenTofu is an open-source alternative to Terraform that is governed by the Linux Foundation. All features available in Terraform 1.5.7 or earlier are also available in OpenTofu. Find out the history of OpenTofu here.

Start using the Terraform platform of the future.

A screenshot of the modules page in the Scalr Platform