I am attempting to limit the quantity of successful code deploy revisions that are preserved on the EC2 instances by editing the codedeployagent.yml
file’s max_revisions
value. I have currently set the value to :max_revisions: 2
.
I believe that the issue I am having is due to the method that I am setting the file value. I am attempting to set the value by deploying it with the code deploy package. To do this I have created a custom codedeployagent.yml
file locally at the following location:
etc/codedeploy-agent/conf/codedeployagent.yml
In my appspec.yml
file I am specifying the installation location of this file by the following lines:
- source: etc/codedeploy-agent/conf/codedeployagent.yml
destination: /etc/codedeploy-agent/conf
I have found that this errors out when I attempt to deploy due to the script already being in place. To work around this, I have added a script that hooks on BeforeInstall
with my appspec.yml
that will remove the script prior to installing the package:
#!/bin/bash
sudo rm /etc/codedeploy-agent/conf/codedeployagent.yml
Okay, so after this I have ssh
’d into the server and sure enough, the :max_revisions: 2
value is set as expected. Unfortunately, in practice I am seeing many more revisions than just two being preserved on the ec2
instances.
So, to go back to the beginning of my question here… Clearly this workaround is not the best way to update the codedeployagent.yml
file. I should add that I am deploying to an auto scaling group, so this needs to be a solution that can live in the deployment scripts or cloud formation templates rather than just logging in and hardcoding the value. With all this info, what am I missing here? How can I properly limit the revisions? Thanks.
Have you restart the agent after updating the config file? Any new configurations won't work until you restart the agent.