Hey all, hope everyone had a merry christmas, I ha...
# help
n
Hey all, hope everyone had a merry christmas, I had a couple questions around the auth construct • Does anyone know how to have a separate email sent for cognito verification and cognito password resets with sst auth? At the moment when i try to do a password reset I get sent the email defined under the property
userVerification
• And does anyone know how to get the emails sent from my own domain (i.e. hello@mydomain.com)? Which is also hosted in aws. I have tried a solution i found online which involved using SES but didn't work as my infra is hosted in ap-southeast-2. So open to any ideas on this one 🙂 Cheers
g
Not 100% sure on the first one but for the second: The @aws-cdk/aws-cognito package should have a UserPoolEmail export that you can setup the following:
Copy code
const auth = new sst.Auth(this, 'MyAuth', {
  userPool: {
    email: cognito.UserPoolEmail.withSES({
      sesRegion: 'us-east-1', // or whatever region your email is in
      fromEmail: '<mailto:hello@mydomain.com|hello@mydomain.com>',
      fromName: 'My App',
      replyTo: '<mailto:hello@mydomain.com|hello@mydomain.com>'
    })
  }
})
n
Hey Garret, thanks for that, have you managed to get that working by anychance? I am on
@aws-cdk/aws-XYZ v1.132.0
and
@serverless-stack v0.53.0
which I don't believe has the class
UserPoolEmail
yet? Maybe introduced in later versions? Also it seems that SSTs auth construct doesn't have an
email
property on their userpool object, they do have an
emailSettings
object which I filled out but still get the following error message
s
@Noah D just to clarify, are you looking for example code on how to handle Cognito emails yourself by hooking into all of the different actions? (password reset, user signup, etc)
a
Just FYI, when I last looked at how to send cognito mails from custom domain, I came to the conclusion that it is not supported by amazon yet for the zone I'm in (eu-central-1).
s
yeah, sounds like a regional limitation. in us-east-1, I can have SendGrid handle all Cognito emails
g
It's definitely possible to send cognito emails from custom domain using ses in any region, you might have to modify the cloudformation directly not sure which version of the CDK introduced the ability to set the ses region.
n
@Sam Hulick yea currently you can use cognito to send email with verification code on signup & password reset. Ideally I would like these emails to come from our domain as well as have a separate one for signup & password reset
@Garret Harp So in theory if i have a verified domain/email in SES in us-east-1 (which i believe lets you send emails via SES), then I should be able to send emails from my cognito service which is hosted in ap-southeast-2 just maybe with some fudging around of cloudformation and or cdk magic?
s
You don't even need to use SES if you don't want to
n
Interesting, would that just involve using a lambda trigger on a certain action and then using a service like sendgrid as you mentioned?
s
I'm happy to give you the code if you'd like 🙂
n
And if so how do you get things like cognito verification codes in there?
Yea would be keen to see an example if possible 🙏
s
sure, gimme a few and I’ll PM you