aws-amplify / aws-amplify/amplify-cli
Custom Email Sender set in auth override.ts is not applied
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
16.9.1
### Amplify CLI Version
10.8.1
### What operating system are you using?
Windows
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual change to Amplify managed resources, but I've added KMS key and email handler lambda manually.
### Describe the bug
Within my project, I had already added 3 auth trigger lambdas via amplify cli.
Then, I needed to add 3rd party email provider support for Cognito user pool.
To achieve this:
1. I've added email handler lambda function and KMS key manually, not managed by amplify. I've also manually added lambda invoke permission for Cognito idp.
2. Then I've added the code below to auth override.ts:
const customEmailSenderProperty = {
lambdaArn: 'arn:aws:lambda:xxx...',
lambdaVersion: 'V1_0',
};
resources.userPool.lambdaConfig = {...resources.userPool.lambdaConfig, customEmailSender:customEmailSenderProperty, kmsKeyId: "arn:aws:kms:xxx.."};
3. I ran amplify push successfully, auth category updated.
4. When I ran "aws cognito-idp describe-user-pool ..." command, I saw that my updates were not applied, just the 3 previous auth triggers listed as below:
"LambdaConfig": {
"PreSignUp": "arn:aws:lambda:xxx",
"CustomMessage": "arn:aws:lambda:yyy",
"PostConfirmation": "arn:aws:lambda:zzz"
}
### Expected behavior
User pool LambdaConfig value should have been updated per override.ts, as below:
"LambdaConfig": {
"PreSignUp": "arn:aws:lambda:xxxx",
"CustomMessage": "arn:aws:lambda:yyyy",
"PostConfirmation": "arn:aws:lambda:zzzz",
"CustomEmailSender": "arn:aws:lambda:wwww",
"kmsKeyId": "arn:aws:kms:pppp"
}
I think there should be a way to update userPool LambdaConfig within override.ts, to add custom email sender.
### Reproduction steps
1. Run amplify add auth
2. Add auth trigger custom lambda via amplify-cli (any trigger type is ok, such as PreSignUp)
3. Add a dummy emailSender lambda function and kms key manually, outside of amplify.
4. Update emailSender lambda permissions:
- Allow kms:Decrypt and kms:DescribeKey actions on kms key
- Give invokeFunction permission to Cognito userpool
6. In IAM console, give kms:createGrant permission to amplify user.
7. Run amplify auth override
8. Customize the auth override.ts with:
const customEmailSenderProperty = {
lambdaArn: 'arn:aws:lambda:xxx...',
lambdaVersion: 'V1_0',
};
resources.userPool.lambdaConfig = {...resources.userPool.lambdaConfig, customEmailSender:customEmailSenderProperty,
kmsKeyId: "arn:aws:kms:xxx.."};
9. amplify push and then check identitiy pool's LambdaConfig value with "aws cognito-idp describe-user-pool .."
### Project Identifier
_No response_
### Log output
```
# Put your logs below this line
```
### Additional information
As an alternative, I may try to:
1. Remove all auth triggers added via amplify-cli
2. Re-add all auth trigger lambda functions with "amplify add function"
3. Then try to add these lambda functions and email sender lambda configuration within auth override.ts
4. Set auth breakCircularDependency feature flag as false
But it requires substantial effort and still I'm not sure if it's going to work. I also don't know whether I can handle environment support. [https://github.com/aws-amplify/amplify-cli/issues/9063]
### Before submitting, please confirm:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Contributor guide
Assessment
This issue has not been assessed yet.