0

I have a CD work flow using CodePipeline + CodeCommit + CodeDeploy to EC2 instances.

I have everything else working except for this --file-exists-behavior option. If I create a deployment from the Aws CLI or the console. The deployment works fine.

Is there anyway I can use this option with CodePipeline?

I am still getting an error without this option.

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

2
  • Similar solution discussed: stackoverflow.com/questions/41590332/… Commented Oct 5, 2017 at 2:27
  • Hi, Kannaiyan, i ve read that question, but it doesnt involve codePipeline. Commented Oct 5, 2017 at 3:03

1 Answer 1

1

So, when you deploy, CodeDeploy will look for a file (on the instance) with information on previously deployed files for the application/deployment-group in question, if it finds the file it then it uses it to cleanup (delete) the existing files, preparing for copying of the new revision files.

Refer This AWS Documentation

But if the cleanup file doesn't exist, either because the existing code was initially deployed in some other way (eg cloudformation instance userdata/metadata sources) or the CodeDeploy deployment-group has been recreated for some reason then the cleanup file will either not exist or not match the deployment-group id. Therefore it wont be run. Therefore the files will not be cleaned up, and the deployment will fail since CodeDeploy does not overwrite files.

What a Solution could be in this scenario is to have a hook (eg BeforeInstall) that calls a script to delete the applications files (if they exist) on the instance.

Hope this helps

Sign up to request clarification or add additional context in comments.

2 Comments

Does it mean, if I deploy the files once with CLI or console once, I dont have to worry about --file-exists-behavior option?
Nope that was for CLI you would still need an script for before install to remove existing file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.