@@ -10,31 +10,14 @@ The following steps demonstrate how to setup the integration tests for auth plug
10
10
11
11
At the time this was written, it follows the steps from here https://docs.amplify.aws/gen2/deploy-and-host/fullstack-branching/mono-and-multi-repos/
12
12
13
- 1 . From a new folder, run ` npm create amplify@latest ` . This uses the following versions of the Amplify CLI, see ` package.json ` file below.
14
-
15
- ``` json
16
- {
17
- ...
18
- "devDependencies" : {
19
- "@aws-amplify/backend" : " ^0.15.0" ,
20
- "@aws-amplify/backend-cli" : " ^0.15.0" ,
21
- "aws-cdk" : " ^2.139.0" ,
22
- "aws-cdk-lib" : " ^2.139.0" ,
23
- "constructs" : " ^10.3.0" ,
24
- "esbuild" : " ^0.20.2" ,
25
- "tsx" : " ^4.7.3" ,
26
- "typescript" : " ^5.4.5"
27
- },
28
- "dependencies" : {
29
- "aws-amplify" : " ^6.2.0"
30
- },
31
- }
32
- ```
13
+ 1 . From a new folder, run ` npm create amplify@latest ` . This will create a new amplify project with the latest version of the Amplify CLI.
33
14
34
- 2 . Update ` amplify/auth/resource.ts ` . The resulting file should look like this
15
+ 2 . Update ` amplify/auth/resource.ts ` . The resulting file should look like this. Replace ` <your_verified_email> ` with your verified email address.
35
16
36
17
``` ts
37
- import { defineAuth , defineFunction } from " @aws-amplify/backend" ;
18
+ import { defineAuth } from ' @aws-amplify/backend' ;
19
+
20
+ const fromEmail = ' <your_verified_email>' ;
38
21
39
22
/**
40
23
* Define and configure your auth resource
@@ -73,6 +56,8 @@ export const auth = defineAuth({
73
56
});
74
57
```
75
58
59
+ 3 . Create a file ` amplify/functions/cognito-triggers/pre-sign-up-handler.ts ` with the following content
60
+
76
61
``` ts
77
62
import type { PreSignUpTriggerHandler } from " aws-lambda" ;
78
63
@@ -92,7 +77,8 @@ export const handler: PreSignUpTriggerHandler = async (event) => {
92
77
return event ;
93
78
};
94
79
```
95
- Create a file ` amplify/data/mfa/index.graphql ` with the following content
80
+
81
+ 4 . Create a file ` amplify/data/mfa/index.graphql ` with the following content
96
82
97
83
``` graphql
98
84
# A Graphql Schema for creating Mfa info such as code and username.
@@ -123,7 +109,7 @@ type MfaInfo {
123
109
}
124
110
```
125
111
126
- Update `amplify /data /mfa /index .ts `. The resulting file should look like this
112
+ 5. Update `amplify /data /mfa /index .ts `. The resulting file should look like this
127
113
128
114
```ts
129
115
import { Duration , Expiration , RemovalPolicy , Stack } from "aws-cdk-lib" ;
@@ -311,9 +297,7 @@ cfnUserPool.addPropertyOverride("DeviceConfiguration", {
311
297
});
312
298
```
313
299
314
- The triggers should look as follows:
315
-
316
- Common
300
+ 6 . Create a file ` amplify/functions/cognito-triggers/common.ts ` with the following content
317
301
318
302
``` ts
319
303
// Code adapted from:
@@ -390,7 +374,7 @@ export const decryptAndBroadcastCode = async (
390
374
};
391
375
```
392
376
393
- custom-email-sender
377
+ 7 . Create a file ` amplify/functions/cognito-triggers/ custom-email-sender.ts ` with the following content
394
378
395
379
``` ts
396
380
import { CustomEmailSenderTriggerHandler } from " aws-lambda" ;
@@ -416,7 +400,8 @@ export const handler: CustomEmailSenderTriggerHandler = async (event) => {
416
400
};
417
401
```
418
402
419
- custom-sms-sender
403
+ 8 . Create a file ` amplify/functions/cognito-triggers/custom-sms-sender.ts ` with the following content
404
+
420
405
421
406
``` ts
422
407
import { CustomSMSSenderTriggerHandler } from " aws-lambda" ;
@@ -439,15 +424,15 @@ export const handler: CustomSMSSenderTriggerHandler = async (event) => {
439
424
};
440
425
```
441
426
442
- 4 . Deploy the backend with npx amplify sandbox
427
+ 9 . Deploy the backend with npx amplify sandbox
443
428
444
429
For example, this deploys to a sandbox env and generates the amplify_outputs.json file.
445
430
446
431
```
447
432
npx ampx sandbox --identifier mfa-req-email --outputs-out-dir amplify_outputs/mfa-req-email
448
433
```
449
434
450
- 5 . Copy the ` amplify_outputs.json ` file over to the test directory as ` XYZ-amplify_outputs.json ` (replace xyz with the name of the file your test is expecting). The tests will automatically pick this file up. Create the directories in this path first if it currently doesn't exist.
435
+ 10 . Copy the ` amplify_outputs.json ` file over to the test directory as ` XYZ-amplify_outputs.json ` (replace xyz with the name of the file your test is expecting). The tests will automatically pick this file up. Create the directories in this path first if it currently doesn't exist.
451
436
452
437
```
453
438
cp amplify_outputs.json ~/.aws-amplify/amplify-ios/testconfiguration/XYZ-amplify_outputs.json
0 commit comments