Raghuram Milkuri
Raghuram Milkuri

Reputation: 91

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

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".

Upvotes: 9

Views: 18533

Answers (6)

ijazahmed Bagawan
ijazahmed Bagawan

Reputation: 101

It's looking for the most recent deployment and if it's not available the above error will occur.

Go into /opt/codedeploy-agent/deployment-root/deployment-instructions/ and delete all the files in there.

Then it won't look for the last deploy.

Upvotes: 7

Prakhar
Prakhar

Reputation: 11

Issue can be fixed by:

  1. Edit your aws codepipeline.
  2. Edit the codedeploy configuration.
  3. select "SourceArtifact" in input artifacts. (This will deploy all the source code to your desired server and location along with appspec.yml file.)

Upvotes: 1

rishikarri
rishikarri

Reputation: 4520

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.

Upvotes: 1

slipperypete
slipperypete

Reputation: 6246

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. 😖

Upvotes: 0

Allen
Allen

Reputation: 2867

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

Upvotes: 15

Aura Herrera
Aura Herrera

Reputation: 246

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.

Upvotes: 6

Related Questions