#! /bin/bash if [ ! -f terragrunt.hcl ]; then echo "ERROR: No terragrunt.hcl in this directory. Aborting." exit 1 fi GITSOURCE=$( cat terragrunt.hcl | egrep -v '^ *#' | egrep 'source *= *.git@github\.mdr' ) if [ "$GITSOURCE" == "" ]; then echo "ERROR: No source from MDR Git detected. Aborting." exit 2 fi # Remove the git URL and the reference if [[ $(pwd) =~ regional ]]; then # Regional directories need an extra layer echo "Regional module detected." NEWPATH=$( echo $GITSOURCE | sed 's#^.*//#../../../../../../xdr-terraform-modules//#' | sed 's/\?.*$//' ) else NEWPATH=$( echo $GITSOURCE | sed 's#^.*//#../../../../../xdr-terraform-modules//#' | sed 's/\?.*$//' ) fi echo Substituting \'$GITSOURCE\' with \'$NEWPATH\' # Test locally # the double // is intentional! Terragrunt uses this to determine the root of the modules repository. terragrunt $* --terragrunt-source $NEWPATH