Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 543 Bytes

README.md

File metadata and controls

23 lines (18 loc) · 543 Bytes

Terraform Targets

Operate (plan or apply) multiple targets without -target subcommand.

#!/usr/bin/env bash

# Output targets if the -t flag is provided
if [[ "$1" == "-t" ]]; then
  terraform plan | ag 'will be' | awk -F'# ' '{print $2}' | awk -F' will be' '{print $1}' | awk '{if(NR>1)print prev " \\"; prev="'"'"'" $0 "'"'"'"} END {print prev}'
  exit 0
fi

ARGS=("${@:2}")
targets=${ARGS[*]/#/-target }
terraform "$1" $targets

Usage:

tt plan 'module.foo.ep_association_s3[0]' 'module.bar.frontend_https[0]'
tt -t