4
votes

The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml".

The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/0bb5a5aa-5894-4575-a69c-a7a4e79b4cdf/d-HQ5GBC7SW/deployment-archive"

The AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/0bb5a5aa-5894-4575-a69c-a7a4e79b4cdf/d-HQ5GBC7SW/deployment-archive/appspec.yml".

4
did you solve this?webish

4 Answers

6
votes

I had the same problem and the other answer helped me reach the right conclusion. In my situation, I had the appspec.yml file in my git repo, but I forgot to add it to the artifact files section. As a result, the appspec.yml wasn't included in the zip and so the deployment step couldn't find it.

In your buildspec.yml, add:

artifacts:
  files:
    - appspec.yml
    - ... other files to include in your build ...

I had some other errors in my deployment configuration too. Looking at the bottom of the log file helped discover them:

less /var/log/aws/codedeploy-agent/codedeploy-agent.log

At one point, my EC2 instance also hung when trying to run a deployment and stopping and restarting the codedeploy agent didn't help. I had to completely restart the EC2 instance.

These docs where helpful: https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html

5
votes

Are you putting the appspec.yml file at root level of your folder bundle? If yes, how are you creating the bundle? If you are just creating a .zip then you need to make sure you are adding the files to the zip instead of a folder.

0
votes

Not the most useful answer. But I had this problem as well as codebuild could not find the scripts defined in appspec.yml I spent a whole day and then at the end just started rebooted the ec2 and it was able to find the scripts. 😖

0
votes

Adding onto Aura's answer which solved it for me. Thank you again Aura! For mac users:

To create a zip with all of the files, open up the folder you want to zip in finder, highlight all of files (use command A), right click and then select "Compress XYZ items".

The mistake you might be making is right clicking on the folder itself and clicking "Compress FolderName".

The problem with compressing the entire folder is that the "unpacked directory" ends up being a directory itself. Hence, when the CodeDeploy agent goes looking for the appspec.yml file, it will see something like this "FolderName/" rather than the contents of the FolderName (which should include an appspec.yml).

Hope this extra detail helps.