s3 backup notifier intends to daily
check the last object date in an AWS S3 bucket, and if it's older than today, send alerting email via AWS Simple Email Service (SES).
I'm using this to monitor the effectiveness of backup of my home automation systems and be alerted on any backup related issue.
Fully serverless.
- Uses AWS Lambda function (Python)
- Rely on AWS Lambda layer for
boto3
andbotocore
- Scheduled Lambda (
daily
) using CloudWatch Events - Uses AWS Simple Email Service (SES) for Emails Notifications
Nb: deployment for my own usage is done using Github Actions, you can check the associated workflow.
- Configure AWS Credentials (prefer aws-vault)
- Create a bucket called:
<project_name>-artifacts
(Prefer versioned and encrypted)
Its using AWS Serverless Application Model (SAM)
Build layer and note the ARN for the deploy step.
$ make layer
And AWS Lambda function package.
$ make package \
PROJECT=<your_project_name>
Deploy CloudFormation stack.
RECIPIENTS var is space-separated
$ make deploy \
PROJECT=<your_project_name> \
ENV=<your_env> \
S3_PREFIX=<buckets_pattern> \
BUCKETS_BLACKLIST=<buckets_to_exclude> \
SENDER=<sender_email> \
RECIPIENTS='recipient_email1,recipient_email2' \
AWS_REGION='<your_aws_region>' \
AWS_SES_REGION='<your_aws_ses_region>' \
BOTOLAYER='<your-boto-layer-name-in-arn>' \
BOTOLAYERVERSION='<your-boto-layer-version-in-arn>'
Remove unused folders and files after the deployment of your stack.
$ make cleaning
$ make tear-down