Search code examples
amazon-web-servicesamazon-ec2aws-code-deployamazon-linux

Is there a way to exclude a directory in AWS CodeDeploy?


We have an auto deployment from BitBucket set up to deploy to one of three EC2 instances. Everything currently works fine except our /data directory (which contains CMS-uploaded images, videos, etc) is not part of the repository. So during deployment, the existing /data directory on the specific instance is removed.

I see that it's possible to set exclusions for file ownership/group and permissions using the "exclude" parameter; however, no such parameter seems to exist for the Files section:

http://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-files.html

It seems as if this would be a common problem, but I haven't been able to find a solution yet. Does anyone have any suggestions for excluding files for overwriting during a deployment?

The only thing I can come up with at this point is to manually specify each directory that is to be overridden as well as each root file in appspec.yml. That's far from ideal, as it would need to be edited each time a new directory or root file is added.


Solution

  • In case others are looking, the solution is to manually specify each directory and/or file via the appspec "files" directive. This way files not included in the list do not get deployed.

    The appspec file will then need to be updated any time a new directory or root file is added.