AWS Code Deploy Error on Before Install Cannot Solve

install codedeploy agent
the deployment failed because a specified file already exists at this location
codedeploy all events skipped
aws codedeploy scripts
directory not empty @ dir_s_rmdir codedeploy
aws code deploy agent status
codedeploy no instances
codedeploy local command not found

So I am attempting to setup CodeDeploy for my application and I keep getting an error during the BeforeInstall part of the deployment. Below is the error.

Error Code UnknownError
Script Name
Message No such file or directory - /opt/codedeploy-agent/deployment-root/06100f1b-5495-42d9-bd01-f33d59fb5deb/d-NL5K1THE8/deployment-archive/appspec.yml
Log Tail

I assumed this meant the YAML file was in the wrong place. However it is in the root directory of my revision. I have tried using a simple AppSpec file like so instead of a more complex one.

    ## YAML Template.
---
version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu/www

More or less since this is a first deployment I want it to add all files in the revision to the public directory on the web server.

I am tearing my hair out over this and I feel it is a simple issue. I have the IAM policies and roles correct and I have CodeDeploy setup and running on my instance I am trying to deploy to.

It seems to think you had a successful deploy at some point.

Go into /opt/codedeploy-agent/deployment-root/deployment-instructions/ and delete all the files in there. Then it won't look for this last deploy.

Troubleshoot EC2/On-Premises Deployment Issues, You may receive the error message "The deployment failed because a If there are files in the target installation folders that aren't listed in this cleanup file, the CodeDeploy Before you delete an application or a deployment group, deploy a revision The script contains an error that cannot be corrected, so it never runs  Install or reinstall the CodeDeploy agent for Windows Server Javascript is disabled or is unavailable in your browser. To use the AWS Documentation, Javascript must be enabled.

I just had this SAME problem and I figured it out! Make sure your AppSpec file has the right EXTENSION! I was using yaml and not yml, now everything works perfectly.

Error Codes for AWS CodeDeploy, Find information about error codes returned during failed CodeDeploy deployments. Make sure the agent is installed and running on all instances in this deployment group. The deployment can't start because the minimum number of healthy instances, Make sure you are using the correct service role name. Troubleshoot deployment issues you might encounter when you use CodeDeploy to deploy to an EC2/On-Premises compute platform.

I made it work like this:

I had a couple of failed deployments for various reasons. The thing is that CD keeps in the EC2 instance and in the path /opt/codedeploy-agent/deployment-root/​ a folder named by the ID of the failed deployment [a very long alphanumeric sting] . Delete this folder and create a new deployment [from the aws UI console] and redeploy the application. This way the appspec.yml file that is in the wrong place will be deleted. It should now succeed.

Extra Notice:

CD does not rewrite files [that have not been created by it's specific deployment] CodeDeploy does not deploy in a folder that there is already code[files] as it does not want to interfere with different CD deployments and/or other CI/CD tools [like Jenkins]. It only deploys in a path that has already deploy code with the specific deployment.

You can empty the folder where your deployment want to happen and redeploy your code via CD.

Troubleshooting CodeDeploy, Use the topics in this section to help solve problems and errors you might encounter when using CodeDeploy. Note. You can identify the causes of many  Diagnosis: The certificate presented by the Web Deploy endpoint is untrusted or invalid. This typically happens if the remote server has a self-signed certificate for the Remote Agent Service or the Web Management Service. Resolution: Either install a trusted certificate on the endpoint, or try bypassing certificate validation.

When you login to the host, do you see the appspec.yml file in the directory there? If not are you positive it has been checked in with the rest of your deployed code?

General troubleshooting issues, To check the version you have installed, call aws --version. If you are still unable to troubleshoot your failed deployment, review the other issues in this topic. Deployment Error: A pipeline configured with an AWS Elastic Beanstalk deploy action hangs instead of failing if the "DescribeEvents" permission is missing Problem: The service role for CodePipeline must include the "elasticbeanstalk:DescribeEvents" action for any pipelines that use AWS Elastic Beanstalk.

Just encountered this issue too. In my case, the revision zip file extracts into a directory when deployed. Because of that /opt/codedeploy-agent/deployment-root/xxx/xxx/deployment-archive contains the parent directory of my revision files (instead of the actual revision files).

The key is to compress your revision without the parent directory. In mac terminal,

cd your-app-directory-containing-appspec
zip -r app.zip . 

AWS Code Deploy Error on Before Install Cannot Solve, It seems to think you had a successful deploy at some point. Go into /opt/​codedeploy-agent/deployment-root/deployment-instructions/ and delete all the files in  AWS CodeDeploy is a building block service focused on helping developers deploy and update software on any instance, including Amazon EC2 instances and instances running on-premises. AWS Elastic Beanstalk and AWS OpsWorks are end-to-end application management solutions. Q: Does AWS CodeDeploy support on-premises instances?

AWS Code Deploy Error on Before Install Cannot Solve, So I am attempting to setup CodeDeploy for my application and I keep getting an error during the BeforeInstall part of the deployment. Below is the error. Error  AWS CodeDeploy makes it easier for you to rapidly release new features, helps you avoid downtime during application deployment, and handles the complexity of updating your applications. You can use AWS CodeDeploy to automate software deployments, eliminating the need for error-prone manual operations.

Setting up an AWS CodeDeploy Deployment Using PowerShell, Learn how to deploy AWS CodeDeploy using PowerShell. This value is what separates manual, error-prone, “do whatever it A software developer's code that solves all of the world's problems doesn't mean anything if it can't be with PowerShell before, you're going to need to download and install the  AWS Lambda and Amazon ECS deployments cannot use an in-place deployment type. Here's how it works: First, you create deployable content on your local development machine or similar environment, and then you add an application specification file (AppSpec file). The AppSpec file is unique to CodeDeploy.

aws/aws-codedeploy-agent, I encountered this error right after upgrading to ubuntu 18 as well - although I am It grants all folders being removed before the actual installation. tlacroix pushed a commit to tlacroix/aws-codedeploy-agent that Issue #185: fix for "​Directory not empty @ dir_s_rmdir - /var/www" on Ubuntu 18.04 #207. Symptoms Web Deploy does not work after a version upgrade. Root Cause: Web Deploy does not restart services after an upgrade. Fix/Workaround: If you are upgrading an existing installation of Web Deploy, make sure to restart the handler and agent services by running the following commands at an administrative command prompt: · net stop msdepsvc & net start msdepsvc · net stop wmsvc & net

Comments
  • did you ever find a solution to this??
  • I have the same issue. Any luck? CodeDeploy is terrible. I think I might go back to jenkins
  • This is actually the answer (or at least it was in my case).
  • Worked, except I was on windows so path is C:\ProgramData\Amazon\CodeDeploy\deployment-instructions
  • Worked, you saved my day!
  • Wasted a whole day before I found this! Not sure how the disconnect happens but in my case all I did was forget to push one of the files in the appSpec. Once I replaced that file in source, this error kept occurring. Thanks @Levitron
  • Worked like a charm!
  • The error specifically states for appspec.yml . I tried it and didnt make a difference
  • You saved my day!
  • deleting the old deployments was 'the fix' for us, too.
  • It is the first deployment so there is no directory in the host yet that has the AppSpec.yml file I do see it in the root directory in the compressed tar file that was setup for the revision to deploy in S3
  • Hrmm, that tarball should end up in /opt/codedeploy-agent/deployment-root/<whatever-uuid>/<deployment-id>/ regardless of a failure or not ( as far as I know) even if its the first deploy. Does that end up there with the rest of your contents or no?