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

feat: add support for SNS->SQS protocol #272

Merged
merged 2 commits into from
Jan 19, 2021

Conversation

heitorlessa
Copy link
Contributor

@heitorlessa heitorlessa commented Jan 19, 2021

Issue #, if available: #265

Description of changes:

When using SNS -> SQS -> Lambda, the SNS payload differs from SNS -> Lambda. It's not explicitly documented as per #262 - This information is available on per Target protocol, and Lambda is the only one that seems to differ from others (e.g. SQS, HTTP, etc.)

This PR does the following:

  • Adjusts MessageAttributes to be an optional field
  • Dynamically adjusts UnsubscribeURL -> UnsubscribeUrl, and SigningCertURL -> SigningCertUrl to make backwards compatible
  • Creates a new envelope SnsSqsEnvelope to make this process seamless for customers

UX

Excerpt from tests, where customers can continue to write their parsing as before, but use a new envelopes.SnsSqsEnvelope to correctly extract the original SNS payload that was doubled marshalled too.

@event_parser(model=MySnsBusiness, envelope=envelopes.SnsSqsEnvelope)
def handle_sns_sqs_json_body(event: List[MySnsBusiness], _: LambdaContext):
    assert len(event) == 1
    assert event[0].message == "hello world"
    assert event[0].username == "lessa"

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@heitorlessa heitorlessa marked this pull request as draft January 19, 2021 10:32
@heitorlessa heitorlessa marked this pull request as ready for review January 19, 2021 13:27
Copy link
Contributor

@nmoutschen nmoutschen left a comment

Choose a reason for hiding this comment

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

LGTM - just 2 small remarks

docs/content/utilities/parser.mdx Show resolved Hide resolved
Copy link
Contributor Author

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

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

responded to comments; merging

docs/content/utilities/parser.mdx Show resolved Hide resolved
Copy link
Contributor Author

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

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

responded to comments; merging

@heitorlessa heitorlessa merged commit b538772 into develop Jan 19, 2021
@heitorlessa heitorlessa deleted the fix/parser-sns-sqs-model branch January 19, 2021 14:01
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

Successfully merging this pull request may close these issues.

2 participants