I am trying to trigger an event bridge rule:
{
"detail": {
"stateMachineArn": ["arn:aws:states:eu-west-2:<account-num>:stateMachine:<target-name>"],
"status": ["SUCCEEDED"]
},
"detail-type": ["detail-type"],
"source": ["aws.states"]
}
I'm trying to put an event to the default bus using the following step in my step-function:
"SendEventToEventBridge": {
"Type": "Task",
"Resource": "arn:aws:states:::events:putEvents",
"Parameters": {
"Entries": [
{
"Source": "aws.states",
"DetailType": "detail-type",
"Detail.$": "$.event",
"EventBusName": "default"
}
]
},
"End": true
}
But I keep getting a NotAuthorizedForSourceException when trying to upload this event in my step function using source 'aws.states'. From what I can tell it's because only AWS Service events can use sources 'aws.'. I thought sending an event from the step function as such would satisfy this condition but it seems not to. I'm struggling to understand, how do I send and event to the bus with the required source of 'aws.states' to satisfy the rule?
The error you’re encountering (NotAuthorizedForSourceException) is due to the fact that the Source field in an EventBridge event must reflect the actual service that is authorized to publish events under that namespace. In your case, aws.states is reserved for AWS Step Functions when it emits its own events (such as ExecutionStarted or ExecutionSucceeded), not for custom events you send through your Step Function.
Instead of using aws.states for your custom event, choose a unique namespace for the Source. For example, use something like my-application or custom.states:
"SendEventToEventBridge": {
"Type": "Task",
"Resource": "arn:aws:states:::events:putEvents",
"Parameters": {
"Entries": [
{
"Source": "custom.states",
"DetailType": "detail-type",
"Detail.$": "$.event",
"EventBusName": "default"
}
]
},
"End": true
}
Updated EventBridge Rule
{
"detail": {
"stateMachineArn": ["arn:aws:states:eu-west-2:<account-num>:stateMachine:<target-name>"],
"status": ["SUCCEEDED"]
},
"detail-type": ["detail-type"],
"source": ["custom.states"]
}