how to prune old CodePipeline artifacts
Every build artifact is 39MB, and every time I submit a build, it adds another 39MB artifact to the codepipeline S3 bucket. Is there a way to automatically delete old artifacts?
You can use S3 lifecycle policies to automatically expire old objects: http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html
Two things to keep in mind when picking an expiration time:
- Deployment providers like CodeDeploy might need access to old versions to scale or roll back
- Your pipeline may take many days or weeks to run depending on how it's configured
So long as you deploy regularly then it should be fine to pick an expiration in the order of a month or so.
If your pipeline rarely runs then it might be harder to expire objects based on age because you might expire a version that's still current.