Code deploy works on running machines - fails on new server from autoscale

0

Took me a bit to narrow down the issue, but what I have is an auto-scaling group with a Java application. The process is quite simply but does the following. When a new WAR file is deployed to CodeCommit repo, the pipeline takes that update, sends to each server. The appspec.yml file is quite simple;

version: 0.0
os: linux
files:
  - source: /
    destination: /opt/deploy
    file_exists_behavior: OVERWRITE
hooks:
   AfterInstall:
     - location: /scripts/update.sh
       timeout: 600
       runas: root

The /scripts/update.sh is nothing more than a java deployment, some logging, etc. and when this is pushed to the server cluster, each machine updates and works perfect.

The problem is when the auto-scaling group triggers and says "we need a new server". There is a lifecycle hook on instance start, so the machine starts, a code-deploy does fire, it gives a success on all the items but it fails to deploy. As I dig deeper, when I look on the instance, I can find the deployID here -> /opt/codedeploy-agent/deployment-root/ and then that deployment. There is a bundle.tar, but more important the deployment-archive which has all the files, etc.

So, when I push an update, code-deploy/pipeline uses the /opt/deploy folder, but when a new instance starts, it is putting it in the above and not respecting that appspec location, so java deploy is failing saying that /opt/deploy/file.war doesn't exist (as it never put it there).

Any help on what I am doing wrong or needs to be updated is appreciated.

asked 9 months ago65 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions