Skip to content

Feature request: Secrets Events #2855

Closed

Description

@koolray

Use case

When setting up secrets rotation you can rotate the secret via a specific lambda, therefore I think having a secrets event would be useful here.

Solution/User Experience

Setting up a secrets event, similar to the way the other events are handled parsing the json object into a dataclass.

Alternative solutions

I'd be happy to help codify this if someone where to help outline the basic requirements.

Acknowledgment

Activity

  1. boring-cyborg commented on Jul 27, 2023

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

  2. leandrodamascena commented on Jul 28, 2023

    @leandrodamascena
    Contributor

    Hi @koolray! Thanks for opening this issue!

    Yeah, this is interesting to add support to this event. If I remember correctly, the payload that AWS Secrets send to Lambda is something like: {"token":"xx", "secretid": "yy", "Step": "zz"}. I need to confirm it.

    Do you have bandwidth to add this support? It would be amazing to have your contribution here.

    Thanks


  3. added
    event_sourcesEvent Source Data Class utility
    and removed
    triagePending triage from maintainers
    on Jul 28, 2023
  4. moved this from Triage to Pending customer in Powertools for AWS Lambda (Python)on Jul 28, 2023
  5. koolray commented on Jul 29, 2023

    @koolray
    Author

    Hey @leandrodamascena, this is the format I've found in the aws docs:

    {
        "Step" : "request.type",
        "SecretId" : "string",
        "ClientRequestToken" : "string"
    }
    

    I have the bandwidth and would be happy to help! Once I create a PR I'll probably need some guidance as to the style and tests that is used in this repo (as I've never contributed before). I will do my best to mimic that of the other classes, but would still appreciate some help.

    If this suits you, let me know

  6. leandrodamascena commented on Jul 29, 2023

    @leandrodamascena
    Contributor

    Hey @leandrodamascena, this is the format I've found in the aws docs:

    {
        "Step" : "request.type",
        "SecretId" : "string",
        "ClientRequestToken" : "string"
    }
    

    I created a secret and rotated it and got this exact event, so it's the payload to Lambda.

    I have the bandwidth and would be happy to help! Once I create a PR I'll probably need some guidance as to the style and tests that is used in this repo (as I've never contributed before). I will do my best to mimic that of the other classes, but would still appreciate some help.

    This is amazing to hear. For sure we can guide you in this first contribution.

    We use Poetry as the package manager and we have a Makefile to make things easier. So basically you need to clone the repository and type make dev to create your development environment. After that, you can do the following steps:

    1 - You need to create a new file called secrets_event.py - Use this class as an example: https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/data_classes/vpc_lattice.py

    2 - You need to export this new class here - https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/data_classes/__init__.py

    3 - You need to create a file with a fake payload here - https://github.com/aws-powertools/powertools-lambda-python/tree/develop/tests/events

    4 - You need to write a new test for this new class - Use this test as an example - https://github.com/aws-powertools/powertools-lambda-python/blob/develop/tests/unit/data_classes/test_vpc_lattice_event.py

    5 - You need to add this new class to the documentation - https://github.com/aws-powertools/powertools-lambda-python/blob/develop/docs/utilities/data_classes.md

    6 - Run the tests by typing make test and after that use make pr to make sure that everything is right.

    7 - If everything is right, just open the PullRequest and have a cold drink 🍹

    Let me know if you get stuck at any of these steps and we can work together to merge your contribution.

  7. moved this from Pending customer to Working on it in Powertools for AWS Lambda (Python)on Jul 29, 2023
  8. moved this from Working on it to Pending customer in Powertools for AWS Lambda (Python)on Aug 1, 2023
  9. koolray commented on Aug 2, 2023

    @koolray
    Author

    Thank you @leandrodamascena! This is great, I will make a start and put a draft PR on the weekend.

    Then, whenever you or anyone else has time we can discuss potential changes to keep everything in line with existing code.

    Thank you very much

  10. moved this from Pending customer to On hold in Powertools for AWS Lambda (Python)on Aug 9, 2023
  11. koolray commented on Aug 14, 2023

    @koolray
    Author

    Hi @leandrodamascena, sorry I've been trying to do this but I wanted to double check that the events came through the way specified (by testing out a secrets rotation on aws) but unfortunately am having lots of problems with the set up. So my progress has ultimately been quite slow. I have also been unable to find any examples online.

  12. leandrodamascena commented on Aug 14, 2023

    @leandrodamascena
    Contributor

    Hello @koolray! I was able to create this event here and confirm that this is the real example. You can consider this payload:

    {
        "Step" : "request.type",
        "SecretId" : "string",
        "ClientRequestToken" : "string"
    }

    Do you think that with this event you can start working to send a PR? If not, don't worry, I can start creating the class and you create the tests, or do a review. Please let me know what you prefer, we'd love to have your first contribution here and we can work together to make it happen. 🚀

  13. self-assigned this
    on Sep 7, 2023
  14. moved this from On hold to Working on it in Powertools for AWS Lambda (Python)on Sep 7, 2023
  15. roger-zhangg commented on Sep 7, 2023

    @roger-zhangg
    Contributor

    Hey @koolray , Thank you so much for this feature request and I've just created the PR with basic implementation. It would be fantastic if you can take a look in that PR and provide some feedback if possible. I also suggested some more utilities in discussion, I would love to see your opinion.

    Thanks!

  16. github-actions commented on Sep 12, 2023

    @github-actions
    Contributor

    ⚠️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.

  17. github-actions commented on Sep 15, 2023

    @github-actions
    Contributor

    This is now released under 2.25.0 version!

  18. moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python)on Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions