Reputation: 3336
I have 4 AWS Lambdas that should read S3 bucket when some file is created (S3 Event), but in cloudformation I just can use 1 Lambda ARN, see inside AWS::S3::Bucket LambdaConfiguration
:
How can I trigger more than 1 Lambda in Bucket Lambda Configuration ?
Upvotes: 3
Views: 277
Reputation: 33779
AWS recently announced S3 Event Notifications with Amazon EventBridge. Consequently, you can enable EventBridge notification on your bucket and then have one (or more) Lambda function(s) triggered by those events.
Example implementation using AWS SAM:
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: 'S3 EventBridge Example'
Parameters:
BucketName:
Type: String
Description: 'Name of the bucket to be created'
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
NotificationConfiguration:
EventBridgeConfiguration:
EventBridgeEnabled: true
S3EventProcessor:
Type: AWS::Serverless::Function
Properties:
FunctionName: S3EventListener
Architectures:
- arm64
Runtime: nodejs14.x
Handler: index.handler
InlineCode: |
exports.handler = (event, context) => {
console.log('event:', JSON.stringify(event));
}
Events:
S3EventBridgeRule:
Type: EventBridgeRule
Properties:
Pattern:
source:
- aws.s3
detail:
bucket:
name:
- !Ref BucketName
Upvotes: 2
Reputation: 1044
I think Step functions is exactly what you want. Also S3-related tutorial can be useful
Upvotes: 1
Reputation: 57134
S3 does not offer this kind of fan-out out-of-the-box but only through e.g. SNS.
You need to push the notification into a SNS topic instead of a lambda and then either
Upvotes: 2