#!/usr/bin/env bash # scripts/tg — wrapper: inject -auto-approve for non-interactive apply # Usage: scripts/tg apply --non-interactive # scripts/tg run --all -- plan # Auth: `vault login -method=oidc` (token at ~/.vault-token) set -euo pipefail # If running apply with --non-interactive, add -auto-approve for Terraform args=("$@") has_apply=false has_non_interactive=false for arg in "${args[@]}"; do case "$arg" in apply) has_apply=true ;; --non-interactive) has_non_interactive=true ;; esac done if $has_apply && $has_non_interactive; then # Rebuild args: insert -auto-approve after apply new_args=() for arg in "${args[@]}"; do new_args+=("$arg") if [ "$arg" = "apply" ]; then new_args+=("-auto-approve") fi done exec terragrunt "${new_args[@]}" else exec terragrunt "$@" fi