skip to Main Content

I have a simple test angular application. I am following a tutorial to learn AWS Code Pipeline and failed in the Code Deploy stage.
Tutorial I am following My angular application GitHub link

Code build is successful. You can see the buildspec.yml file in the GitHub link provided. But, the Code deploy stage fails giving me the below error in the BeforeBlockTraffic stage.

CodeDeploy agent was not able to receive the lifecycle event. Check the CodeDeploy agent logs on your host and make sure the agent is running and can connect to the CodeDeploy server.

I got to know that this is a policy-related issue. But, I have enabled full access to my ec2 machine. Here is the policy list currently enabled. Am I missing any policy here ?

enter image description here

Below is the appspec.yml file I am using. Am I missing anything in this file as well ??

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/html/
hooks:
  BeforeInstall:
    - location: scripts/remove_root_dir
      timeout: 900
      runas: root
  ApplicationStart:
    - location: scripts/install_dependencies
      timeout: 300
      runas: root
    - location: scripts/start_server
      timeout: 300
      runas: root
  ApplicationStop:
    - location: scripts/stop_server
      timeout: 300
      runas: root

2

Answers


  1. Check if you have enabled the CodeDeploy agent on your ec2 machine. You can also log in to your ec2 machine and perform the below steps to install the CodeDeploy agent manually.

    sudo yum update
    sudo yum install ruby
    sudo yum install wget
    wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
    chmod +x ./install
    sudo ./install auto
    
    Login or Signup to reply.
  2. My agent was installed but it dodn’t have the IAM Account attached to the instance. I had to do the follwoing:

    • Opened code deploy console
    • Select the instance
    • In Actions, Select Security -> Modify IAM role
    • Select the IAM role
    • Restart the instance
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search