New Features
New Features
July 22, 2021

New Feature: Custom Hooks

By
Ryan Fee

We’re happy to announce custom hooks that make it easier to customize your Terraform workflow while using Scalr as the remote backend.

Scalr makes it easier to automate and collaborate with your colleagues, but we recognize that different organizations and teams might have unique workflows, which is why we have now added the custom hooks feature within workspaces.

Problem

Normally, users are accustomed to running Terraform from their laptop or an environment where they have the freedom to have a completely custom runtime environment. When running Terraform in a remote backend, you are restricted to what is already installed in that environment … until now.

Solution

Custom hooks allow you to execute any command you would normally run in a Linux command line before and/or after the plan and before and/or after the apply. Common use cases are:

  • Executing tools (tflint, checkov, etc) before a plan to run lint or security tests
  • Pulling the plan JSON and uploading it to a third party system
  • Install software needed as part of your Terraform run before the plan or apply
  • Triggering API calls to a third party (Slack, Teams, etc) after the run has successfully completed.

Here is what it looks like in the workspace settings:

How to Get Started

To try the hooks out, go to the settings of any one of your workspaces where you will find the custom hooks section. As seen in the screenshot above, just enter in your standard commands, which are passed to the runtime environment and executed as part of the run. The output can be found in the plan and apply output:

Log in to try it out for yourself and check out more examples in the docs.

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