Reputation: 5168
TLDR; How do I only push to CodeDeploy the changes that have been made from CodeCommit?
I built a simple CI/CD Pipeline with CodePipeline in which I commit to CodeCommit and then it deploys the code using CodePipeline to my Elastic Beanstalk application.
The problem is that it seems like it simply copies the entire application and puts it online. In this way, it removes all of the logs that I had previously on the server. For example, anything that was in .gitignore will not only not be submitted to git, but if this was previously on the server, then it will be removed.
Any comments or suggestions are greatly appreciated! ❤️
Thanks!
Upvotes: 2
Views: 1488
Reputation: 238229
In this way, it removes all of the logs that I had previously on the server
EB environment, whether single-instance or load-balance always runs in autoscaling group. This means that they can be terminated at any time, e.g. due to AZ re-balance or due to changes to your EB environment configuration
Thus you should build all your applications to be stateless and do not depend on any stored information on them. Sooner or later this will lead to issues (some of which you are experiencing now).
Upvotes: 2
Reputation: 35188
If you wanted to do this upon a CodePipeline activation you would need to have a first stage that prunes based on the difference of commits (presumably using Lambda). This would then replace the artifact that goes to your instances.
Remember that CodeDeploy will replace the contents of the folder with the contents of your artifact so you'll need to account for this.
However this is generally bad practice, in fact you should never be reliant on a specific server especially for logging.
Instead architect your servers to ship your logs to a distributed service such CloudWatch Logs, an ELK stack or a third party supplier. Always be prepared for your infrastructure to fail, by allowing servers to be easily replaced it will allow your applications to be more resilient.
Upvotes: 1