Skip to content

Custom Commands

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.

Run a custom command during a Terrateam operation:

  • Pre workflow: one time per operation
  • Post workflow: one time per operation
  • Part of a workflow: one time per workflow in an operation

Hooks are executed a single time pre and post a Plan or Apply operation. Workflows can replace the default workflow steps Terrateam executes during an operation.

In the following example:

  • Echo statements are written to the console pre and post Plan and Apply operations.
  • Environment variables are echoed to the console using the cmd parameter for Plan and Apply workflow steps that run against each targeted Dirspace in the operation.
  • $TERRATEAM_DIR: Current working directory for the Dirspace.
  • $TERRATEAM_WORKSPACE: Workspace that is currently being executed against 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']
We use cookies and similar technologies to provide certain features, enhance the user experience and deliver content that is relevant to your interests. Depending on their purpose, analysis and marketing cookies may be used in addition to technically necessary cookies. By clicking on "Agree and continue", you declare your consent to the use of the aforementioned cookies. Here you can make detailed settings or revoke your consent (in part if necessary) with effect for the future. For further information, please refer to our Privacy Policy .