Reputation: 484
I have created a lambda function in my sam template and have added a Eventbridge rule linked to s3 bucket trigger the lambda whenever a file arrives inside the bucket. However, when i add a new file in the s3 bucket the lambda function does nottriggered.
below is code for lambda function
TimeFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: cc-dummy-eventbridge-lambda
Handler: lambda_function.lambda_handler
Runtime: python3.9
CodeUri: ./TimeZone
Role: !FindInMap
- StagesMap
- Ref: Environments
- RoleEnv
Events:
GetEvent:
Type: EventBridgeRule
Properties:
Pattern:
source:
- "aws.s3"
detail:
eventName:
- "PutObject"
- "PutObjectAcl"
- "CopyObject"
requestParameters:
bucketName:
- !FindInMap [StagesMap, !Ref Environments, SOURCEBUCKET]
My eventbridge rule pattern that has been created:
Event pattern:
{
"source": [
"aws.s3"
],
"detail": {
"requestParameters": {
"bucketName": [
"dummy-dev"
]
},
"eventName": [
"Object Created"
]
}
}
What am i missing in code that will enable the eventbridge trigger to work ?
Upvotes: 0
Views: 662
Reputation: 484
I have managed to fix the eventbridge issue by changing the detail-type and changing the bucketname. i have added the code below that has fixed the issue that i was having
GetEvent:
Type: EventBridgeRule
Properties:
EventBusName: default
Pattern:
source:
- "aws.s3"
detail-type:
- Object Created
detail:
bucket:
name:
- !FindInMap [StagesMap, !Ref Environments,SOURCEBUCKET]
Upvotes: 0