Tuyen Nguyen
Tuyen Nguyen

Reputation: 1

CodeDeploy running outdated appspec, scripts file

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:

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).

Upvotes: 0

Views: 647

Answers (1)

Tuyen Nguyen
Tuyen Nguyen

Reputation: 1

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.

Upvotes: 0

Related Questions