Skip to content

Hooks

Hooks can be used to run commands or set environment variables pre and post Workflows. Pre and post hooks are only executed a single time during a Terrateam Operation. Commands are executed from the repository checkout directory $TERRATEAM_ROOT.

Terrateam Configuration Terrateam behavior can be configured via a config.yml. This file is located in a directory named .terrateam at the root of your Terraform repository: .terrateam/config.yml.

See Configuration documentation for details.

Configuration

Top-level key: hooks

See Configuration Reference documentation for details.

KeyTypeDescription
allAllPre and post hook configuration to run around all operations.
planPlanPre and post hook configuration for Plan operations.
applyApplyPre and post hook configuration for Apply operations.

Default configuration:

hooks:
  all:
    pre: []
    post: []
  plan:
    pre: []
    post: []
  apply:
    pre: []
    post: []
All

All

KeyTypeDescription
prePreCommands to run before any hooks.
postPostCommands to run after any hooks.

Pre

Commands to run before any hooks.

KeyTypeDescription
typeStringPre-hook type: env, run.
Env
KeyTypeDescription
nameStringName of environment variable.
cmdListCommand to use to set environment variable.
trim_trailing_newlinesBooleanTrim trailing newlines. Default is true.
Run
KeyTypeDescription
cmdListCommand to run from the directory that Terrateam is operating against.
run_onStringRun the command on step success, failure, or always. Default is success.
capture_outputBooleanWhen capture_output is set to true, command output is included in the GitHub pull request comment on a failure. Sensitive data is not masked. Be aware, this data is sent back to the Terrateam backend for processing. Default is false.

Post

Commands to run after any hooks.

KeyTypeDescription
typeStringPost-hook type: env, run.
Env
KeyTypeDescription
nameStringName of environment variable.
cmdListCommand to use to set environment variable.
trim_trailing_newlinesBooleanTrim trailing newlines. Default is true.
Run
KeyTypeDescription
cmdListCommand to run from the directory that Terrateam is operating against.
run_onStringRun the command on step success, failure, or always. Default is success.
capture_outputBooleanWhen capture_output is set to true, command output is included in the GitHub pull request comment on a failure. Sensitive data is not masked. Be aware, this data is sent back to the Terrateam backend for processing. Default is false.
Plan

Plan

KeyTypeDescription
prePreCommands to run before a plan workflow.
postPostCommands to run after a plan workflow.

Pre

Commands to run before a Plan workflow.

KeyTypeDescription
typeStringPre-hook type: env, run.
Env
KeyTypeDescription
nameStringName of environment variable.
cmdListCommand to use to set environment variable.
trim_trailing_newlinesBooleanTrim trailing newlines. Default is true.
Run
KeyTypeDescription
cmdListCommand to run from the directory that Terrateam is operating against.
run_onStringRun the command on step success, failure, or always. Default is success.
capture_outputBooleanWhen capture_output is set to true, command output is included in the GitHub pull request comment on a failure. Sensitive data is not masked. Be aware, this data is sent back to the Terrateam backend for processing. Default is false.

Post

Commands to run after a Plan workflow.

KeyTypeDescription
typeStringPost-hook type: env, run.
Env
KeyTypeDescription
nameStringName of environment variable.
cmdListCommand to use to set environment variable.
trim_trailing_newlinesBooleanTrim trailing newlines. Default is true.
Run
KeyTypeDescription
cmdListCommand to run from the directory that Terrateam is operating against.
run_onStringRun the command on step success, failure, or always. Default is success.
capture_outputBooleanWhen capture_output is set to true, command output is included in the GitHub pull request comment on a failure. Sensitive data is not masked. Be aware, this data is sent back to the Terrateam backend for processing. Default is false.
Apply

Apply

KeyTypeDescription
prePreCommands to run before an apply workflow.
postPostCommands to run after an apply workflow.

Pre

Commands to run before a Apply workflow.

KeyTypeDescription
typeStringPre-hook type: env, run.
Env
KeyTypeDescription
nameStringName of environment variable.
cmdListCommand to use to set environment variable.
trim_trailing_newlinesBooleanTrim trailing newlines. Default is true.
Run
KeyTypeDescription
cmdListCommand to run from the directory that Terrateam is operating against.
run_onStringRun the command on step success, failure, or always. Default is success.
capture_outputBooleanWhen capture_output is set to true, command output is included in the GitHub pull request comment on a failure. Sensitive data is not masked. Be aware, this data is sent back to the Terrateam backend for processing. Default is false.

Post

Commands to run after a pply workflow.

KeyTypeDescription
typeStringPost-hook type: env, run.
Env
KeyTypeDescription
nameStringName of environment variable.
cmdListCommand to use to set environment variable.
trim_trailing_newlinesBooleanTrim trailing newlines. Default is true.
Run
KeyTypeDescription
cmdListCommand to run from the directory that Terrateam is operating against.
run_onStringRun the command on step success, failure, or always. Default is success.
capture_outputBooleanWhen capture_output is set to true, command output is included in the GitHub pull request comment on a failure. Sensitive data is not masked. Be aware, this data is sent back to the Terrateam backend for processing. Default is false.