3
votes

I am deploying via CodeDeploy a logstash configuration in a target instance in /etc/logstash/.

This is the last step in a 3-staged CodePipeline.

However it fails with message

The deployment failed because a specified file already exists at this location: /etc/logstash/pipelines.yml

How can I instruct CodeDeploy to overwrite files?

3
as my answer gets deleted because "it's not tailored", although i feel it is, see stackoverflow.com/questions/41590332/…. - Seirddriezel

3 Answers

3
votes

Currently, the only way I have seen that you can overwrite files is selecting to overwrite or retain, as seen here, when you're creating a new deployment. In no other place will you see those settings. And if I'm not mistaken, this is the only way to do it because it is not supported on the CLI.

July 2021 Update: Looks like AWS has finally acknowledged this defect -- look here for updates on all that.

0
votes

An issue to add an overwrite option is open on GitHub and it has been there for quite a while. I solved this by adding a custom script in the BeforeInstallation hook which will erase all existing files before copying over my new deployment.

This is how my appspec.yml file looks like

version: 0.0
os: linux
files:
  - source: /
    destination: /path/to/destination
hooks:
  BeforeInstall:
    - location: DeploymentScripts/CleanupScript.sh
  AfterInstall:
    - location: DeploymentScripts/InstallScript.sh
      timeout: 600
  ApplicationStart:
    - location: DeploymentScripts/RestartScript.sh
      timeout: 3600
-1
votes

You can pass this attribute in the appspec.yml under

files : overwrite: true