You can connect as many buckets as you like by using S3 Event Notifications
The VirusScan for Amazon S3 with additional integrations is available in the AWS Marketplace.
- Uses ClamAV to scan newly added files on S3 buckets
- Updates ClamAV database every 3 hours automatically
- Scales EC2 instance workers to distribute workload
- Publishes a message to SNS in case of a finding
- Delete infected files if needed
- Logs to CloudWatch Logs
- S3 -> SNS -> VirusScan for Amazon S3 support
- Multi-Account support
- Quarantine infected files
- CloudWatch Integration (Metrics and Dashboard)
- Security Hub Integration
- SSM OpsCenter Integration
The VirusScan for Amazon S3 with additional integrations is available in the AWS Marketplace.
A picture is worth a thousand words:
- A SQS queue is used to decouple scan jobs from the ClamAV workers. Each S3 bucket can fire events to that SQS queue in case of new objects. This feature of S3 is called S3 Event Notifications.
- The SQS queue is consumed by a fleet of EC2 instances running in an Auto Scaling Group. If the number of outstanding scan jobs reaches a threshold a new ClamAV worker is automatically added. If the queue is mostly empty workers are removed.
- The ClamAV workers run a simple ruby script that executes the clamscan command. In the background the virus db is updated every three hours.
- If
clamscan
finds a virus the file is directly deleted (you can configure that) and a SNS notification is published.
- This templates depends on one of our
vpc-*azs.yaml
templates. Launch Stack - Launch Stack
- Click Next to proceed with the next step of the wizard.
- Specify a name and all parameters for the stack.
- Click Next to proceed with the next step of the wizard.
- Click Next to skip the Options step of the wizard.
- Check the I acknowledge that this template might cause AWS CloudFormation to create IAM resources. checkbox.
- Click Create to start the creation of the stack.
- Wait until the stack reaches the state CREATE_COMPLETE
Configure the buckets you want to connect to as shown in the next figure:
Make sure you select the -ScanQueue- NOT the -ScanQueueDLQ-!
If you like to receive emails if a virus was found you must subscribe to the SNS topic as shown in the next two figures:
You will receive a confirmation email.
The VirusScan for Amazon S3 with additional integrations is available in the AWS Marketplace.
- Go to CloudWatch Logs in the AWS Management Console
- Click on the log group of the s3-virusscan
- Click on the blue Search Log Group button
- Search for
"s3-virusscan["
- It was reported that the solution does not run on a t2.micro or smaller. Use at least a t2.small instance.
- An initial scan may also be useful but is not performed at the moment. This could be implemented with a Lambda function that pushes every key to SQS.