Eliya
Eliya

Reputation: 155

Monitor S3 - Send an alert if more than 5 minutes have passed since a last file was written

I have a program that uploads files to S3 every 5 minutes. I need to monitor it. So I want to check every 10 minutes what is the time of the last file uploaded and if it more than X minutes sends an alert (email) about it. I understand that I need to use CloudWatch and Lambda. But I don't know how to do it. Any help, please.

Upvotes: 0

Views: 491

Answers (1)

Jens
Jens

Reputation: 21510

The following AWS products should help you build this:

  1. AWS EventBridge (formerly known as CloudWatch Events)
  2. AWS Lambda
  3. AWS SES

Solution outline:

  1. Create your Lambda function.
  2. Create a scheduled event rule in EventBridge.
  3. When creating the rule, use a rate of 10 minutes.
  4. Set your Lambda from step 1. as target of your rule.
  5. When your Lambda is triggered, run your business logic to check when the last file was uploaded.
  6. If you need to send an email, you can use AWS SES to send it to your recipients.

Important:

  1. You need to allow AWS EventBridge to call your Lambda. If you do all of this in the AWS console, the required permissions should be set automatically. If you use CloudFormation, Terraform or SAM, you probably need to add those permissions to your Lambda.

Upvotes: 1

Related Questions