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']