Skip to content

Commit 827cf20

Browse files
authored
update auth example for "moving to production" email with senders (#8020)
* update auth example for "moving to production" email with `senders` * update jsdoc links
1 parent a390eb2 commit 827cf20

File tree

1 file changed

+41
-24
lines changed
  • src/pages/[platform]/build-a-backend/auth/moving-to-production

1 file changed

+41
-24
lines changed

src/pages/[platform]/build-a-backend/auth/moving-to-production/index.mdx

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,50 @@ To get started with Amazon SES in production, you must first [request production
4444

4545
After you have configured your account for production access and have verified your _sender_ email, you can configure your Cognito user pool to send emails using the verified sender:
4646

47-
```ts title="amplify/backend.ts"
48-
import { Stack } from "aws-cdk-lib/core"
49-
import { EmailIdentity } from "aws-cdk-lib/aws-ses"
50-
import { defineBackend } from "@aws-amplify/backend"
51-
import { auth } from "./auth/resource"
52-
53-
const backend = defineBackend({
54-
auth,
47+
```ts title="amplify/auth/resource.ts"
48+
import { defineAuth } from "@aws-amplify/backend"
49+
50+
/**
51+
* Define and configure your auth resource
52+
* @see https://docs.amplify.aws/react/build-a-backend/auth
53+
*/
54+
export const auth = defineAuth({
55+
loginWith: {
56+
email: true,
57+
},
58+
senders: {
59+
email: {
60+
// configure using the email registered and verified in Amazon SES
61+
fromEmail: "registrations@example.com",
62+
},
63+
},
5564
})
56-
57-
const { cfnUserPool } = backend.auth.resources.cfnResources
58-
const authStack = Stack.of(cfnUserPool)
59-
60-
const email = EmailIdentity.fromEmailIdentityName(
61-
authStack,
62-
"EmailIdentity",
63-
// your email configured for use in SES
64-
process.env.EMAIL
65-
)
66-
67-
cfnUserPool.emailConfiguration = {
68-
emailSendingAccount: "DEVELOPER",
69-
sourceArn: email.emailIdentityArn,
70-
}
7165
```
7266

73-
Now when emails are sent on new user sign-ups, password resets, etc., the sending account will be your verified email.
67+
Now when emails are sent on new user sign-ups, password resets, etc., the sending account will be your verified email! To customize further, you can change the display name of the sender, or optionally apply a custom address for your users to reply.
68+
69+
```ts title="amplify/auth/resource.ts"
70+
import { defineAuth } from "@aws-amplify/backend"
71+
72+
/**
73+
* Define and configure your auth resource
74+
* @see https://docs.amplify.aws/react/build-a-backend/auth
75+
*/
76+
export const auth = defineAuth({
77+
loginWith: {
78+
email: true,
79+
},
80+
senders: {
81+
email: {
82+
fromEmail: "registrations@example.com",
83+
// highlight-start
84+
fromName: "MyApp",
85+
replyTo: "inquiries@example.com"
86+
// highlight-end
87+
},
88+
},
89+
})
90+
```
7491

7592
## SMS
7693

0 commit comments

Comments
 (0)