terragrunt-local 905 B

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