This project creates an S3 bucket that holds logs and then archives them using Glacier.
We used Terraform for IaC and we're going to use Ansible to deploy log store Python scripts onto EC2 Instances.
Cronjobs then run these scripts every night to upload logs to the bucket.
After a day, the lifecycle rules of the bucket will move them to ONEZONE_IA
and after a week to Glacier
so We can have them in cold storage.
You need these pre-requisites in the machine you're using the script in:
- You need Python 3 and pip
- Run
pip install boto3
For the machine that you use to create the bucket, Terrafom
must be installed.
An AWS account with preferred permissions.
- Clone this repo and then populate the secrets with your credentials.
- Run
terrafom plan
and thenterrafom apply
- After the creation use the bucket name from the output.
- Set environment variables in the machine that you want to store its logs.
- Copy
uploader.py
into that machine and copy it into/usr/loca/bin
. - Make the script executable.
- Use
crontab -e
to create the cronjob and then schedule it for the time you want.
- Add Ansible Playbooks.
- Add uploader script.