Refer first chiplunkarshubham/aws_code_deploy as this is the continuation and userdata can also be found there.
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.
sudo yum erase codedeploy-agent -y
cd /opt
sudo rm -r codedeploy-agent/
sudo ./install auto