[AWSINTS-3517] feat(go-forwarder): add EventBridge#1119
Merged
ndakkoune merged 6 commits intoMay 11, 2026
Conversation
ndakkoune
commented
May 7, 2026
| eventSourceKinesis = "aws:kinesis" | ||
| ) | ||
|
|
||
| func Parse(event json.RawMessage) ([]ParsedEvent, error) { |
Contributor
Author
There was a problem hiding this comment.
[]ParsedEvent instead of ParsedEvent because the future SQS PR will have to handle multiple records
ViBiOh
reviewed
May 7, 2026
| if err != nil { | ||
| return nil, fmt.Errorf("read record key: %w", err) | ||
| } | ||
| if key != eventSourceKey && key != eventSourceSNSKey { |
Contributor
There was a problem hiding this comment.
To have case insensitive comparison, you can use strings.EqualFold
Comment on lines
+76
to
+78
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } |
Contributor
There was a problem hiding this comment.
You can use testify/assert to have something like assert.NoError(t, err)
Contributor
Author
There was a problem hiding this comment.
Will make a codebase test update in a separate PR.
Comment on lines
+80
to
+91
| if len(got) != len(tc.want) { | ||
| t.Fatalf("got %d events, want %d", len(got), len(tc.want)) | ||
| } | ||
|
|
||
| for i, pe := range got { | ||
| if pe.ContentType != tc.want[i] { | ||
| t.Errorf("event[%d]: got ContentType %v, want %v", i, pe.ContentType, tc.want[i]) | ||
| } | ||
| if len(pe.Payload) == 0 { | ||
| t.Errorf("event[%d]: empty payload", i) | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| if len(got) != len(tc.want) { | |
| t.Fatalf("got %d events, want %d", len(got), len(tc.want)) | |
| } | |
| for i, pe := range got { | |
| if pe.ContentType != tc.want[i] { | |
| t.Errorf("event[%d]: got ContentType %v, want %v", i, pe.ContentType, tc.want[i]) | |
| } | |
| if len(pe.Payload) == 0 { | |
| t.Errorf("event[%d]: empty payload", i) | |
| } | |
| } | |
| assert.Equal(t, tc.want, got) |
| }) | ||
|
|
||
| g.Go(func() error { | ||
| eg.Go(func() error { |
| for _, parsedEvent := range parsedEvents { | ||
| handler, err := handling.NewHandler(parsedEvent.ContentType, cfg) | ||
| if err != nil { | ||
| return err |
| dec := json.NewDecoder(bytes.NewReader(event)) | ||
|
|
||
| if t, err := dec.Token(); err != nil || t != json.Delim('{') { | ||
| return "", errors.New("decode eventbridge source: expected '{'") |
Contributor
There was a problem hiding this comment.
Suggested change
| return "", errors.New("decode eventbridge source: expected '{'") | |
| return "", errors.New("decode source: expected '{'") |
| if err != nil { | ||
| return nil, fmt.Errorf("build s3 event from eventbridge: %w", err) | ||
| } | ||
| return []ParsedEvent{{ContentTypeS3, s3Event}}, nil |
Contributor
There was a problem hiding this comment.
Add field name and do not rely on struct ordering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds EventBridge as supported event (both S3 and Cloudwatch) + refactor parsing logic to extract the payloads.
Motivation
Testing Guidelines
Additional Notes
Types of changes
Check all that apply