AWS CodeDeploy Github File Already Exists

I am trying to use AWS CodeDeploy to transfer my latest changes from Github to the server. The problem I encountered is in the installation phase. I get this error:

Error CodeUnknownError Script Name MessageFile already exists at location /data/sites/wordpress/api_now_playing_staging.php Log Tail 

And my apppec.yml looks like this:

 version: 0.0 os: "linux" files: - source: "/" destination: "/data/sites/wordpress" permissions: - object: /data/sites/wordpress pattern: "**" owner: wp group: nginx mode: 755 type: - file 

My question is whether git should be pulled out with CodeDeploy, why am I getting a file of an existing error? Am I doing something wrong?

+4
source share
4 answers

Have you deployed the same git repos with a different deployment group or did it manually before? If the same resource already exists in the destination folder, CodeDeploy checks to see if the resource in the destination folder is created by the same deployment group. If you use the same deployment group, redeployment should not cause this problem.

The current CodeDeploy host agent works to pull the deployment artifacts and transfer them to the right repository according to the AppSpec file. Even you deploy from the Github repository, it doesn’t just run git in the destination folder.

+2
source

Because the file already exists on the server, CodeDeploy has hooks (BeforeInstall) that can be used to run custom scripts to clean up existing files, since codedeploy Install does not override the files if they already exist.

+1
source

All other answers are correct, but, in my opinion, cannot solve your problem. However, they are a good starting point. (short: codedeploy sees a file that was not supposed to be there in the previous codedeploy)

This is resolvable during deployment: "Content Options: Select the action for AWS CodeDeploy to take during deployment when the file in the target instance has the same name as the file in the application version for the same target location."

You can select reject, overwrite and save. Overwrite is probably the best choice in your case.

You can not find more information.

+1
source

I did it like this:

I had several failed deployments for various reasons. The fact is that the CD is stored in the EC2 instance and in the path / opt / codedeploy-agent / deployment-root / a folder, named by the identifier of the failed deployment [very long alphanumeric sting]. Delete this folder and create a new deployment [from the aws UI console] and redeploy the application. He must now succeed.

Note. The CD does not overwrite files [that were not created by its specific deployment]

CodeDeploy is not deployed to a folder where the code [files] already exists, since it does not want to interfere with the deployment of CDs and / or other CI / CD tools [for example, Jenkins]. It is deployed only along a path that already deploys code with a specific deployment.

You can empty the folder where you want to deploy and redeploy your code using the CD.

0
source

All Articles