How awslabs/cdk-serverless-clamscan works
Main Components
• AWS CDK Construct: Represent the construct that users instantiate within their CDK stacks to deploy and integrate the clamscan functionality.
• S3 Buckets: Show the buckets from which objects are uploaded and that trigger the scanning process.
• AWS Lambda Functions:
• One or more Lambda functions implementing the scanning workflow.
• There are at least two Lambda function variants in the assets directory (e.g., “download_defs” to update the ClamAV virus definitions and “scan” to perform the actual scanning).
• Container images as part of the Lambda function deployment (indicating Docker bundling to package ClamAV with the required configurations like “clamd.conf”).
• Event Rules & Destinations:
• The architecture leverages event-driven patterns. For instance, scan results can be routed to SNS topics, SQS queues, or EventBridge (as shown in the example code).
• Configuration & Build Tools:
• Elements like Projen configuration (for project generation/automation) and test directories to indicate continuous integration and automated testing.
• Supporting Resources:
• API documentation and additional configuration files (such as .eslintrc.json, .flake8, etc.) help provide context about coding standards and automation.
Relationships and Interactions
• AWS Lambda (Scan) → External Notification Services:
• AWS Lambda (Download Definitions) → AWS Lambda (Scan): Illustrate the periodic or event-triggered updates of the ClamAV database definitions.
• CDK Construct → AWS Resources: Show that with a single construct instantiation in a CDK stack, all these resources (buckets, Lambdas, event rules) are set up and wired together.
Architectural Patterns & Design Principles
• Event-Driven Architecture: Emphasize the decoupling between S3 events (the trigger) and the processing via Lambda functions, with support for different notification channels.
• Containerized Lambda Deployments: The use of Docker bundling for Lambda functions ensures that ClamAV and related dependencies are packaged reliably.
• Modularity and Extensibility: The design provides extension points (e.g., using “add_source_bucket” or customizing scan result destinations) which promotes configurable behaviors.
Incorporate Relevant Technologies, Frameworks, or Libraries
• AWS CDK (for deploying clouds resources).
• AWS Lambda (with container image support).
• Amazon S3 (storage and event triggering).
• AWS SNS, SQS, and EventBridge (for downstream event targets).
• Docker (for local bundling of Lambda container images).
• Projen (to manage project configuration and maintain consistency across constructs).