admin管理员组

文章数量:1333476

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?

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?

Share Improve this question asked Nov 20, 2024 at 17:20 Nyle AllissNyle Alliss 4711 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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"]
}

本文标签: amazon web servicesHow to create event bus events with source 39aws39Stack Overflow