Skip to main content

Custom Commands

Hooks are executed a single time before and after a Terrateam run.

Workflows can replace the default workflow steps for a dirspace.

info

Order of operations:

  1. Pre-command hooks executed a single time
  2. Workflow steps for all targeted dirspaces
  3. Post-command hooks executed a single time

In the following example, environment variables are echoed using the cmd parameter for all workflow steps running against a dirspace.

  • $TERRATEAM_DIR: current working directory for the dirspace
  • $TERRATEAM_WORKSPACE: workspace that is currently being executed against for the dirspace
hooks:
plan:
pre:
- type: run
cmd: ['echo', 'pre-plan-hook']
post:
- type: run
cmd: ['echo', 'post-plan-hook']
apply:
pre:
- type: run
cmd: ['echo', 'pre-apply-hook']
post:
- type: run
cmd: ['echo', 'post-apply-hook']
workflows:
- tag_query:
plan:
- type: init
- type: run
cmd: ['echo', 'pre-plan-workflow', '$TERRATEAM_DIR', '$TERRATEAM_WORKSPACE']
- type: plan
- type: run
cmd: ['echo', 'post-plan-workflow', '$TERRATEAM_DIR', '$TERRATEAM_WORKSPACE']
apply:
- type: init
- type: run
cmd: ['echo', 'pre-apply-workflow', '$TERRATEAM_DIR', '$TERRATEAM_WORKSPACE']
- type: apply
- type: run
cmd: ['echo', 'post-apply-workflow', '$TERRATEAM_DIR', '$TERRATEAM_WORKSPACE']