4
votes

I'm using AWS CodeDeploy to deploy my project (triggered by CodePipeline) to an autoscaling group (EC2 instances behind an ALB). This is my appSpec file:

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/html/test-deploy
    overwrite: true
permissions:
  - object: /var/www/html/test-deploy/codedeploy
    pattern: "*.sh"
    owner: root
    group: root
    mode: 755
    type:
      - file
hooks:
  BeforeInstall:
    - location: codedeploy/before_install.sh
      timeout: 180
  AfterInstall:
    - location: codedeploy/after_install.sh
      runas: centos
      timeout: 180

The files get deployed successfully to the EC2 instance, but for some reason after the "BeforeAllowTraffic" nothing happens, like I waited 15 min and the next step was still at "pending".

The two .sh files do nothing fancy (and codedeploy passed those steps so I don't think that's the problem).

Can anyone point me to a direction? I don't get any error messages, so I don't even know how to debug it.

Thanks

3

3 Answers

5
votes

I have got the same issue, after investigation, I found that my target group was "unhealthy". I just add the health check path/file i.e "/rorbots.txt" and rebooted the Ec2 Server and its fixed the problem.

0
votes

We also had an unhealthy target instance. The problem was hosting two applications on the same instance, where one (application A) was responsible for health checks and talking to the load balancer, and the other one (application B without any open network ports) was being deployed. One instance was always getting stuck in AllowTraffic during app B deployments. I found the root cause when I looked at the target group for app A and saw that same instance in the "unhealthy" status, so of course deploying app B wasn't going to fix that. After I re-deployed app A and restored the instance back to health, app B deployments were able to progress.

0
votes

Check your logs on your target group instances. It may be caused by one of the following:

  • the application startup command did not finish successfully
  • the application is not running due to an error
  • your target group's health check is NOT configured with the endpoint you expect
  • your application is NOT responding at the endpoint you expect