0

I configured appspec.yml as below: `

version: 0.0
os: linux
files:
 - source: /war/stg/ROOT.war
    destination: /opt/iplass01/tomcat/webapps/
file_exists_behavior: OVERWRITE
hooks:
  ApplicationStop:
    - location: scripts/stop_tomcat_server
      timeout: 300
      runas: root
  AfterInstall:
    - location: scripts/delete_root_resource
      timeout: 300
      runas: root
  ApplicationStart:
    - location: scripts/start_tomcat_server
      timeout: 300
      runas: root

` Scenario as below:

  • Step 1: Run CodeDeploy successully
  • Step 2: Change something on appspec.yml or scripts. Ex: stop_tomcat_server, delete_root_resource, start_tomcat_server
  • Step 3: Run CodeDeploy again but result is failed.
  • ...
  • Step N: Run CodeDeploy again but result is still failed.

Do you have any idea to resolved that's problems?

Expectation: Step 2: when we update appspec.yml or scripts and run CodeDeploy again CodeDeploy will run successfully with up to date configuration(appspec.yml or scripts).

1 Answers1

0

Root cause:

  • During a deployment, the CodeDeploy agent runs the scripts specified for ApplicationStop, BeforeBlockTraffic, and AfterBlockTraffic in the AppSpec file from the previous successful deployment. (All other scripts are run from the AppSpec file in the current deployment.) So, that's mean when If ApplicationStop is error --> deployment can fail.

Solution:

  • Use the CodeDeploy console to create a deployment. On the Create deployment page, under ApplicationStop lifecycle event failure, choose Don't fail the deployment to an instance if this lifecycle event on the instance fails.
  • Use the AWS CLI to call the create-deployment command and include the --ignore-application-stop-failures option.

Reference document:https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-deployments-lifecycle-event-failures.