Skip to content

Feature request: Parser support for custom resource #2295

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

Closed
2 tasks done
ran-isenberg opened this issue May 19, 2023 · 9 comments · Fixed by #2335
Closed
2 tasks done

Feature request: Parser support for custom resource #2295

ran-isenberg opened this issue May 19, 2023 · 9 comments · Fixed by #2335
Assignees
Labels
feature-request feature request parser Parser (Pydantic) utility

Comments

@ran-isenberg
Copy link
Contributor

ran-isenberg commented May 19, 2023

Use case

CFN Custom resource can trigger a lambda function with a set of events: create, delete and update.
There's a clear envelope and user payload which makes it a classic candidate for the parser.
I printed the actual events and wrote an event generator for testing purposes in my own application.
here's the gist: https://gist.github.com/ran-isenberg/9a49fad3d607245f7d615696353d1a36

Solution/User Experience

@event_parser(model=UserModel, envelope=envelopes.CustomResourceEnvelope)
def handler(event: UserModel, context: LambdaContext):
    assert event.password1 == event.password2

Alternative solutions

No response

Acknowledgment

@ran-isenberg ran-isenberg added feature-request feature request triage Pending triage from maintainers labels May 19, 2023
@ran-isenberg
Copy link
Contributor Author

I can work on it later this month if that's ok with you

@rubenfonseca
Copy link
Contributor

@heitorlessa
Copy link
Contributor

Careful here, envelope could lead to resources being deleted: aws-powertools/powertools-lambda-java#1081

[on various meetings :/ so being brief]

@ran-isenberg
Copy link
Contributor Author

ran-isenberg commented May 22, 2023

@heitorlessa any unhandled exception can cause that. I think decorator usage in this case is less ideal. But regular parse function with try/except is fine.
Are you ok with me working on it nonetheless?
I'm planning a blog post on the subject and would like to showcase the parser too.

@ran-isenberg
Copy link
Contributor Author

For reference: typed structs from Go: https://github.com/aws/aws-lambda-go/blob/771b391678d3f54bfa38531774d656f5e0f2ab58/cfn/event.go

it's similar to my gist, but it's not accurate 100%. OldResourceProperties does not appear in create/delete events. Only in update from my experience.

@heitorlessa
Copy link
Contributor

heitorlessa commented May 22, 2023 via email

@ran-isenberg
Copy link
Contributor Author

@heitorlessa np, then model it is.
I'm familiar with the helper, we use it too.

@leandrodamascena
Copy link
Contributor

Hi @ran-isenberg! So in this case, can you send the PR to add this support?

We are planning to release a version on Friday, so if you can send the PR by then we can include it in the next version, if not we will include it in the next release.

Thank you!

@leandrodamascena leandrodamascena added parser Parser (Pydantic) utility and removed triage Pending triage from maintainers labels May 24, 2023
@leandrodamascena leandrodamascena self-assigned this May 30, 2023
@leandrodamascena leandrodamascena linked a pull request May 30, 2023 that will close this issue
10 tasks
@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request feature request parser Parser (Pydantic) utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants