Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CodeDeploy Fail: The deployment failed because a specified file already exists at this location

Tags:

I am trying to set AWS Code deploy with Github to automate my deloyment. the problem i am having is the ec2 instance is already active and has the web app code. the problem is there is also other content on the instance that I don't want under source control. Code deploy is failing with the following error:

The deployment failed because a specified file already exists at this location 

this is because the source code is on the instance and was not added as a revision.

So my question is there any way to make the code deploy recognise the current files on the instance as an inital revision?

like image 547
Lonergan6275 Avatar asked Jan 11 '17 11:01

Lonergan6275


2 Answers

This is possible! This is an option during a deployment: "Content options: Choose the action for AWS CodeDeploy to take during a deployment when a file on a target instance has the same name as a file in the application revision, for the same target location."

You can choose fail, overwrite and retain. Retain is probably the best choice in your case.

You can find more information

  • docs.aws.amazon.com (strangely under 'rollback')

  • cli docs.aws.amazon.com (see --file-exists-behavior (string))

like image 91
Seirddriezel Avatar answered Sep 20 '22 15:09

Seirddriezel


You can simply delete the entire contents of your web root and allow CodeDeploy to update it. Any type of deployment will replace the entire contents.

If you're feeling unsure then copy the webroot to another folder, and in the very unlikely event of a failure you can copy it all back.

Deployments often fail when a file has been modified on the disk, I assume CodeDeploy is checking the modified time of the file.

like image 38
Nico Westerdale Avatar answered Sep 20 '22 15:09

Nico Westerdale