[terragrunt] xxx-all系で個別処理にパイプやリダイレクト等の処理を追加する方法のパイプで出力を渡す先をtfnotifyに変更するだけ。
具体的には下記のような感じのscriptを用意して、
* 下記のような作りなら、ディレクトリ移動(terragrunt plan-all等が行ってくれていること)をterragrunt側に依存しておくことで、terragrunt moduleへの対応を自分で書かずに済む。
/usr/scr/app/script/tfwrapper.sh
# !/bin/bash
set -eu
terraform "$@" 2>&1 | tee ./terraform.log
type=$(echo "$@" | awk '{print $1}')
if [ "$type" != "plan" ] && [ "$type" != "apply" ]; then
exit 0
fi
current_directory=$(pwd)
tfnotify --config "$TF_NOTIFY_FILE_PATH" "$type" --message "$TF_VAR_env $current_directory" < ./terraform.log
下記のように呼び出す
$ terragrunt plan-all --terragrunt-non-interactive --terragrunt-tfpath /usr/src/app/script/tfwrapper.sh
プロジェクトルート以外で、terragrunt.hclが存在しているディレクトリ内で個別にterragrunt plan
やterragrunt apply
を実行すると依存順序(terragrunt.hclで定義したdependencies)が解決されないので、tfnotifyをそのまま使いたければ現状上記方法で解決するしかないと思います。