Skip to content

Conversation

@seb-cr
Copy link
Contributor

@seb-cr seb-cr commented Jul 31, 2024

Our current offline SQS event payload contains only the message body. This is insufficient in applications where we need to inspect the metadata of received messages, and leads to TypeError in the consumer during testing.

This PR adds the missing fields to the event, trying to be relatively accurate. For example, the source queue ARN includes the correct queue name and AWS account ID. In terms of overall structure, an SQSEvent type is helpfully provided in the @types/aws-lambda package, which I've used to ensure our mocked event meets expectations.

Complete event samples can be found here for reference: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html

Jira: ENG-3437

Copy link
Member

@corinja corinja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks ok to me.

Sidenote: I'm not thrilled about the alai library. Maybe I misunderstand it but it looks like a single line of code, and the name is not memorable or descriptive. Perhaps just me, though.

@seb-cr
Copy link
Contributor Author

seb-cr commented Jul 31, 2024

Sidenote: I'm not thrilled about the alai library. Maybe I misunderstand it but it looks like a single line of code, and the name is not memorable or descriptive. Perhaps just me, though.

Oh, but it is both memorable and descriptive, once you've seen it: AWS Lambda Account ID

We love acronyms at CR don't we? 😁

In all seriousness though, I agree; we should probably alias the import so that the actual function identifier is something meaningful like getAccountIDFromARN. I'll happily approve a PR for that if you fancy creating one.

@seb-cr seb-cr merged commit e5db5e6 into master Aug 1, 2024
@seb-cr seb-cr deleted the ENG-3437/complete-offline-sqs-event branch August 1, 2024 08:34
@github-actions
Copy link

github-actions bot commented Aug 1, 2024

🎉 This PR is included in version 2.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants