Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling custom EventBridge events #675

Closed
martoncsikos opened this issue Mar 11, 2024 · 4 comments
Closed

Handling custom EventBridge events #675

martoncsikos opened this issue Mar 11, 2024 · 4 comments

Comments

@martoncsikos
Copy link
Contributor

martoncsikos commented Mar 11, 2024

Hello,

My handler setup:

export const handler = configure({
  app,
  respondWithErrors: false,
  eventSourceRoutes: {
    AWS_EVENTBRIDGE: '/eventbridge',
  },
});

Event I'm sending via Eventbridge from one of my services:

{
  "version": "0",
  "id": "46499334-c300-8408-1b83-105d847df24c",
  "detail-type": "test",
  "source": "mycustomservice",
  "account": "12345678910",
  "time": "2024-03-11T14:17:01Z",
  "region": "eu-central-1",
  "resources": [],
  "detail": {
    "foo": "bar"
  }

I'm getting the following error: Error: Unable to determine event source based on event.

I believe the root cause is this:

event.source.startsWith('aws.') && // Might need to adjust this for "Partner Sources", e.g. Auth0, Datadog, etc

The event with source mycustomservice is not accepted, because the event source does not start with aws.

The aws. prefix is reserved for events originating from AWS owned services, it's not allowed for custom events.

Per AWS docs the Minimum information needed for a valid custom event is only this much:

{
  "detail-type": "event name",
  "source": "event source",
  "detail": {
  }
}

Is it necessary to check the .aws prefix in the source?
Would it be possible to just check the existence of the minimally required keys in the event and accept them as EventBridge events if they do? That would make it possible to handle customer owned events.
Until then, is it possible to work around this with a custom request mapper?

Awesome library btw, thanks for the great work! Happy to create a PR if needed.

@brettstack
Copy link
Collaborator

Hey @martoncsikos , if you remove that one line will the rest of the selection criteria work for your event? If so, I'm happy to merge a PR removing that line. If not, we may need to consider a new event like AWS_EVENTBRIDGE_CUSTOM with less selective criteria. Happy to merge either and can assist where needed (it's not too much; mostly copy-paste-modify)

@martoncsikos
Copy link
Contributor Author

Hey @brettstack, yes I have tested this in our environment and removing that one line works perfectly fine. I created the PR, just removing the line seems lower impact, so I went with that.

@brettstack
Copy link
Collaborator

Thanks @martoncsikos ! I appreciate the contribution.

@martoncsikos
Copy link
Contributor Author

No problem, thanks for the quick resolution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants