https://github.com/magnetikonline/aws-cloudfront-log-expire
Processes S3 buckets configured as CloudFront distribution access log targets - removing log objects prior to a specified expiry date or days.
https://github.com/magnetikonline/aws-cloudfront-log-expire
aws cloudfront s3
Last synced: about 2 months ago
JSON representation
Processes S3 buckets configured as CloudFront distribution access log targets - removing log objects prior to a specified expiry date or days.
- Host: GitHub
- URL: https://github.com/magnetikonline/aws-cloudfront-log-expire
- Owner: magnetikonline
- License: mit
- Created: 2016-03-16T21:38:05.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2022-02-09T04:52:37.000Z (over 4 years ago)
- Last Synced: 2025-02-28T23:29:33.026Z (over 1 year ago)
- Topics: aws, cloudfront, s3
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS CloudFront log expire
Processes an S3 bucket configured as a [CloudFront](https://aws.amazon.com/cloudfront/) distribution access log target - removing all access log objects prior to a specified expiry date or days.
- For safety, will only consider objects for deletion that meet the CloudFront access log naming format.
- By default will only _simulate_ the processing of logs before actual removal from S3 (providing the `--commit` argument will enable actual deletes).
- Can optionally display script processing output back to the users terminal.
- Requires [Boto 2](https://github.com/boto/boto).
- AWS credentials expected to be provided either via shell environment variables or the usual places [Boto will check](https://boto.cloudhackers.com/en/latest/boto_config_tut.html).
## Usage
```
usage: cloudfrontlogexpire.py [-h] --s3-bucket-name NAME
[--s3-bucket-log-prefix PREFIX]
[--expire-before YYYY-MM-DD]
[--expire-days DAY_COUNT] [--progress]
[--commit]
Remove AWS CloudFront access log archives from an S3 bucket before a given
date or number of expiry days.
optional arguments:
-h, --help show this help message and exit
--s3-bucket-name NAME
S3 bucket holding CloudFront access log archives
--s3-bucket-log-prefix PREFIX
S3 bucket path prefix to access log archives
--expire-before YYYY-MM-DD
expire log archives before given date
--expire-days DAY_COUNT
expire log archives older than X number of days
--progress display progress of access log archive processing
--commit delete access log archives, otherwise simulation only
```
Notes:
- Must specify one of `--expire-before` or `--expire-days` - not both.
- Script will *never* delete bucket objects unless the `--commit` argument is provided.