- Newest
- Most votes
- Most comments
Yes, AWS CodeDeploy does have built-in functionality to clean up various logs and deployment artifacts automatically. Here's how it works:
-
CodeDeploy Agent Logs: For Amazon Linux, Ubuntu Server, and RHEL instances, the CodeDeploy agent automatically rotates log files located in the
/var/log/aws/codedeploy-agentfolder. This rotation occurs daily at midnight (instance time). The rotated log files follow a naming pattern ofcodedeploy-agent.YYYYMMDD.log. These log files are automatically deleted after seven days, helping to manage disk space. -
Application Revision Deployment Logs: CodeDeploy provides an option to control the number of application revisions and their associated log files to retain. This can be configured using the
:max_revisions:option in the agent configuration file. You can specify any positive integer to determine how many revisions to keep. If not specified, CodeDeploy defaults to retaining the five most recent revisions plus the currently deployed revision. -
Deployment Folders: During redeployments or rollbacks, CodeDeploy automatically attempts to clean up files from previous deployments. It does this by checking a cleanup file located at:
/opt/codedeploy-agent/deployment-root/deployment-instructions/deployment-group-ID-cleanupfor Linux-based instancesC:\ProgramData\Amazon\CodeDeploy\deployment-instructions\deployment-group-ID-cleanupfor Windows Server instances
This cleanup file is used to remove all listed files from the instance before starting a new deployment, helping to manage disk space and maintain a clean deployment environment.
It's important to note that while CodeDeploy provides these automated cleanup mechanisms, it always retains the log file of the last successful deployment, even if the number of failed deployments exceeds the number of retained revisions. This ensures that you always have access to the logs from your most recent successful deployment for troubleshooting or auditing purposes.
Sources
Working with the CodeDeploy agent - AWS CodeDeploy
Redeploy and roll back a deployment with CodeDeploy - AWS CodeDeploy
Relevant content
asked 5 years ago
asked 2 years ago
