title: ApplicationStop in aws codepipeline failing everytime
body: <p>I am new to AWS. I have created a AWS codepipeline using terraform. When I execute that, codedeploy is always failing at &quot;ApplicationStop&quot; event. It is giving the generic message &quot;The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.&quot;</p>
  <p>When I look at the events there is no error code.</p>
  <p>The following is the buildspec.yml file I am using.</p>
  <pre><code>version: 0.2
  
  phases:
    install:
      runtime-versions:
        java: corretto8
      commands:
        - echo Nothing to do in the install phase...
    pre_build:
      commands:
        - echo Nothing to do in the pre_build phase...
    build:
      commands:
        - echo Build started on `date`
        - mvn install
    post_build:
      commands:
        - echo Build completed on `date`
  artifacts:
    files:
      - 'target/cpproject.war'
      - 'appspec.yml'
      - 'scripts/before_install.sh'
      - 'scripts/after_install.sh'    
      - 'scripts/start_server.sh'
      - 'scripts/stop_server.sh'
  </code></pre>
  <p>The following is the appspec.yml file I am using</p>
  <pre><code>version: 0.0
  os: linux
  files:
    - source: target/cpproject.war
      destination: apache-tomcat-8.5.72/webapps/
  hooks:
    BeforeInstall:
      - location: scripts/before_install.sh
        timeout: 300
        runas: root
    AfterInstall:
      - location: scripts/after_install.sh
        timeout: 300
        runas: root
    ApplicationStart:
      - location: scripts/start_server.sh
        timeout: 300
        runas: root
    ApplicationStop:
      - location: scripts/stop_server.sh
        timeout: 300
        runas: root
  </code></pre>
  <p>The corresponding shell script files I am using are</p>
  <p>before_install.sh</p>
  <pre><code>#!/bin/bash
  rm -rf apache-tomcat-8.5.72/webapps/cpproject*
  </code></pre>
  <p>after_install.sh</p>
  <pre><code>#!/bin/bash
  #
  </code></pre>
  <p>stop_server.sh</p>
  <pre><code>#!/bin/bash
  isExistApp=`pgrep java`
  if [[ -n  $isExistApp ]]; then
     apache-tomcat-8.5.72/bin/shutdown.sh
  fi
  </code></pre>
  <p>start_server.sh</p>
  <pre><code>#!/bin/bash
  apache-tomcat-8.5.72/bin/startup.sh
  </code></pre>
  <p>Can anyone help me with what exactly I am doing wrong here? Thanks in advance.</p>