Skip to main content

Workflows

The workflows directive can be used to replace the default workflow steps Terrateam executes during a run.

workflows:
- tag_query: ""
plan:
- type: init
- type: plan
extra_args: ["-parallelism=1"]
apply:
- type: init
- type: apply
extra_args: ["-parallelism=1"]

Use-cases

Keys

KeyTypeDescription
tag_querystringA list of all tags that must be present in a tag set in order to match the workflow

Learn more

Default Configuration

The default workflow configuration for a terrateam plan and terrateam apply is as follows:

workflows:
- tag_query: ""
plan:
- type: init
- type: plan
apply:
- type: init
- type: apply

plan

  • Step 1: terraform init
  • Step 2: terraform plan

apply

  • Step 1: terraform init
  • Step 2: terraform apply
note

The terraform command cannot be replaced by another command.

The only exception is when the terragrunt key is set to true.

Tag Query

A tag_query can use any combination of implicit and custom tags to create a match.

Learn more

Configurations

ConfigurationTypeDescription
terragruntboolOverride the terraform command with terragrunt. Default is false.
terraform_versionstringOverride the terraform version
planobjectConfiguration for plan steps
applyobjectConfiguration for apply steps

Subkeys

ConfigurationTypeDescription
extra_argsarrayExtra command line arguments passed to the terraform command

Extra Args

Pass extra command line arguments to the terraform command.

Learn more

Terragrunt

Replace the terraform command with terragrunt.

Learn more

Terraform Version

Override the Terraform version specified in default_tf_version.

Parameters

env

ParameterTypeDescription
namestringName of environment variable
cmdarrayCommand to use to set environment variable
trim_trailing_newlinesboolTrim trailing newlines. Default is true.

run

KeyTypeDescription
cmdarrayCommand to run from the directory that Terrateam is operating against
run_onstringRun the command on step success, failure, or always. Default is success.
envobjectList of environment variables to set for this execution. Object keys are environment variable names and the value is a string.

Examples

Replace Terraform with Terragrunt

workflows:
- tag_query: ec2
terragrunt: true

Extra Terraform Arguments

workflows:
- tag_query: ec2 us-east-1
apply:
- type: apply
extra_args: ["-var-file=../vars/us-east-1-variables.tfvars"]

Custom Commands

workflows:
- tag_query: ec2 production
plan:
- type: init
- type: run
cmd: ["echo", "ec2", "plan", "workflow", "start"]
- type: plan
- type: run
cmd: ["echo", "ec2", "plan", "workflow", "finish"]
run_on: always

Multiple Terraform Versions

workflows:
- tag_query: ec2 us-east-1
terraform_version: 1.2.2
- tag_query: ec2 us-west-1
terraform_version: 0.15.5