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 custom Lambda function email senders in Auth construct #2087

Open
wants to merge 99 commits into
base: main
Choose a base branch
from

Conversation

vigy02
Copy link

@vigy02 vigy02 commented Oct 7, 2024

Problem

This PR addresses the need for more flexible email sender configuration in the Auth construct, specifically allowing the use of custom Lambda functions for email sending capabilities.

Changes

  • Added support for using Lambda functions as email senders in the Auth construct
  • Implemented KMS key management for custom email senders
  • Updated types and interfaces to accommodate new email sender options
  • Added new test case for custom email sender functionality
  • Modified existing code to handle Lambda function email senders, including permission setup

Validation

A new test case was added to verify the behavior when a function is provided as an email sender. This test ensures that the custom email sender is properly set up when a Lambda function is provided.

Checklist

  • If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.

const authWithTriggerFactory = defineAuth({
loginWith: { email: true },
//if senders aren't passed its essentially lambdaTriggers={}
triggers: { preSignUp: funcStub },
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks good, but it should also include email senders function here. this is so we can test there are no conflicts between the two

Copy link
Contributor

Choose a reason for hiding this comment

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

ie, make sure the trigger exists for presignup, and also the custom sender function

props.senders?.email &&
props.senders.email instanceof lambda.Function &&
this.customEmailSenderKmsKey
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if all of this code is necessary if we use .addTrigger on this.userPool, for example:

this.userPool.addTrigger(UserPoolOperation.of('customEmailSender'), props.senders.email)

Copy link
Contributor

@awsluja awsluja Oct 11, 2024

Choose a reason for hiding this comment

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

You can check to see if the template generates/includes the necessary IAM policies and KMS key resource.
Its essentially what we do today for the other triggers

// (No @packageDocumentation comment for this package)
```
Copy link
Contributor

Choose a reason for hiding this comment

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

im not sure why this file is here, perhaps you have to pull from main again

Copy link
Member

Choose a reason for hiding this comment

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

yep, this file shouldn't be here.
and it seems it has whitespace changes.

for the purpose of this pr just remove this from diff please.

to prevent this from happening you can try the following:

  1. What @awsluja said above - merge latest main
  2. Clean - rebuild
  3. Check these settings https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings (the diff seems to be whitespace changes).

},
},
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also verify that the KMS key resource exists ?

vigy02 and others added 21 commits October 14, 2024 12:21
* detect transform errors with multiple errors

* new method of getting multiple transform errors
* Add minify option to defineFunction

* Add unit tests and e2e tests when set minify option to false

* Add changeset

* Update API.md

* add bundling options

* Update .changeset/pink-rockets-dance.md

* use optional chaining

* include funcNoMinify into function.ts

---------

Co-authored-by: Kamil Sobol <[email protected]>
* Fix cdk tests when new dependencies are shipped to npm.

* try this

* try this

* try this

* try this
…lify-backend into feature/custom-email-function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-e2e Label that will include e2e tests in PR checks workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants