Reputation: 115
I have an EventBridge that receives events and want to publish it to SQS that triggers Lambdafunction using sam template
putting events on EventBridge is ok, but the SQS doesn't have been trigger by the EventBridge
do I have any errors in the following yaml
eventSqsQueue:
Type: AWS::SQS::Queue
eventSynchronizer:
Type: AWS::Serverless::Function
Properties:
CodeUri: build/eventSynchronizer
Handler: eventSynchronizer.Handler
Events:
MySQSEvent:
Type: SQS
Properties:
Queue: !GetAtt eventSqsQueue.Arn
BatchSize: 10
eventEventRule:
Type: AWS::Events::Rule
Properties:
EventPattern:
account:
- !Sub '${AWS::AccountId}'
source:
- "microserviceName"
DetailType:
- "event Created"
- "event Updated"
- "event Deleted"
Targets:
- Arn: !GetAtt eventSqsQueue.Arn
Id: "SQSqueue"
EventBridgeToToSqsPolicy:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: events.amazonaws.com
Action: SQS:SendMessage
Resource: !GetAtt eventSqsQueue.Arn
Queues:
- Ref: eventSqsQueue
Upvotes: 1
Views: 1552
Reputation: 17140
If you want to check your template for errors, use
$ sam validate
More info here : https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-validate.html
Upvotes: 0
Reputation: 115
DetailType
should be detail-type
and with some delete to extra written code
Here is the final solution
eventSqsQueue:
Type: AWS::SQS::Queue
eventSynchronizer:
Type: AWS::Serverless::Function
Properties:
CodeUri: build/eventSynchronizer
Handler: eventSynchronizer.Handler
# ReservedConcurrentExecutions: 1
Events:
MySQSEvent:
Type: SQS
Properties:
Queue: !GetAtt eventSqsQueue.Arn
BatchSize: 10
eventEventRule:
Type: AWS::Events::Rule
Properties:
Description: "eventEventRule"
EventPattern:
source:
- "microserviceName"
detail-type:
- "event Created"
- "event Updated"
- "event Deleted"
Targets:
- Arn: !GetAtt eventSqsQueue.Arn
Id: "SQSqueue"
EventBridgeToToSqsPolicy:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: events.amazonaws.com
Action: SQS:SendMessage
Resource: !GetAtt eventSqsQueue.Arn
Queues:
- Ref: eventSqsQueue
```
Upvotes: 3