Hello Janvi,
Please ensure the below things, me too had same error.
Install or reinstall the CodeDeploy agent for Amazon Linux or RHEL
sudo yum update
sudo yum install ruby
sudo yum install wget
cd /home/ec2-user
wget
https://aws-codedeploy-ap-south-1.s3.ap-south-1.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
Policy for EC2InstanceProfileIAMRole
AmazonEC2RoleforAWSCodeDeploy
AmazonS3FullAccess
Policy for CodeDeployServiceROle
AWSCodeDeployRole
I guess you are having your code on your S3 Bucket, if please mention it revision name as below given in codedeploy deployment section.
s3://codedeoployitboundry/cdeploy/SampleApp_Linux.zip
Note: Not full permission recommended i belive you are experimenting in you lab.