I set up CodeDeploy with BitBucket. So I can deploy my latest commits via Bitbucket UI. But every deploy it creates a bundle.tar on instances to this directory /opt/codedeploy-agent/deployment-root/
I tried to add a hook AfterInstall
, simple bash script that just finds and removes created bundle but it gives me an error now. Nothing in logs. Here is my appspec.yml file:
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html/mysite.com
permissions:
- object: /var/www/html/mysite.com
pattern: "**"
owner: user
group: www
mode: 444
type:
- file
- object: /var/www/html/mysite.com
pattern: "**"
owner: user
group: www
mode: 555
type:
- directory
hooks:
AfterInstall:
- location: /usr/local/scripts/deploy/remove-bundle-after-deploy.sh
timeout: 180
runas: root
Here is the remove-bundle-after-deploy.sh
file:
#!/bin/bash
find /opt/codedeploy-agent/deployment-root/ -type f -name bundle.tar -exec rm -f {} +
How to set up CodeDeploy to not create bundle.tar files at all on my instances? Is that possible? If not, how can I remove them after successful deploy?
You can actually configure the max revisions you want CodeDeploy to store.
http://docs.aws.amazon.com/codedeploy/latest/userguide/host-cleanup.html#host-agent-cleanup