瀏覽代碼

Merge pull request #146 from mdr-engineering/feature/ftd_na_UpdateApplyAllToAutoContinue

`bin/terragrunt-apply-all` now continues automatically if there is no error
Frederick Damstra 4 年之前
父節點
當前提交
c991a88111
共有 1 個文件被更改,包括 13 次插入7 次删除
  1. 13 7
      bin/terragrunt-apply-all

+ 13 - 7
bin/terragrunt-apply-all

@@ -92,6 +92,7 @@ if [[ ! $PARENT_PWD =~ ^aws ]]; then
 fi
 
 for i in `seq -f "%g*" 0 9 | sort -n`; do
+  EXITCODE=1 # Assume error
   MODULE=$( basename $i )
   if [[ -d $MODULE ]]; then
     echo "====================================================================================="
@@ -116,6 +117,7 @@ for i in `seq -f "%g*" 0 9 | sort -n`; do
           [[ $TESTING ]] && ${TERRAGRUNT_BIN} plan  # Run a plan if testing
           [[ $TESTING ]] || ${TERRAGRUNT_BIN} init  # Run an init and apply
           [[ $TESTING ]] || ${TERRAGRUNT_BIN} apply
+          EXITCODE=$?
           popd > /dev/null
           echo "========== Region completed: $i"
         fi
@@ -124,21 +126,25 @@ for i in `seq -f "%g*" 0 9 | sort -n`; do
       [[ $TESTING ]] && ${TERRAGRUNT_BIN} plan  # Run a plan if testing
       [[ $TESTING ]] || ${TERRAGRUNT_BIN} init  # Run an init and apply otherwise
       [[ $TESTING ]] || ${TERRAGRUNT_BIN} apply
+      EXITCODE=$?
     fi
     popd > /dev/null
     echo "=======================================DONE=========================================="
     echo ""
     echo ""
 
-    # Prompt to continue after each module. Easier than ctrl-c...
-    read -p "Terragrunt completed. Continue to next module [Y/n]? " -n 1 -r
-    echo ""
-    if [[ $REPLY =~ ^[Nn]$ ]]
-    then
-        echo Exiting...
-        exit 0
+    if [[ $EXITCODE != 0 ]]; then
+      # Prompt to continue after each module. Easier than ctrl-c...
+      read -p "Terragrunt completed. Continue to next module [Y/n]? " -n 1 -r
+      echo ""
+      if [[ $REPLY =~ ^[Nn]$ ]]
+      then
+          echo Exiting...
+          exit 1
+      fi
     fi
   fi
 done
 
 echo Finished.
+exit 0