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 ?
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
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.
My agent was installed but it dodn’t have the IAM Account attached to the instance. I had to do the follwoing: