I was getting the same issue while testing the service hooks, then I checked my deployment group name in AWS was different then the 'environments' value in Github, I changed to have the same value in both places. now it works.
And make sure the the IAM user you are using is having codeDeployAccess permission. In my case it is this or you can use the AWS existing policy for this, i.e 'AWSCodeDeployDeployerAccess'.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "codedeploy:*",
"Resource": "*"
}
]
}
Though it still show this error when I test the web hook service in Github but it really works when I push my code, some people mentioned the same as well in this post. So even though your web hook test shows error, you can ahead and test with a real git push.