Open ggj0418 opened 5 months ago
I was looking into contributing this feature into the repo and I saw #2087 merged yesterday, so I would like to figure some things out before diving deeper if that's okay.
The feature introduced this new type:
export type CustomEmailSender = {
handler: IFunction;
kmsKeyArn?: string;
};
If I want to implement CustomSmsSender
using the same strategy as CustomEmailSender
, it would have the same fields(a handler and a KMS key) but CloudFormation expects the KMS key to be inside the LambdaConfig
, not a specific sender.
My question is, should we have two KMS keys or the current structure needs to be refactored in order to also have CustomSmsSender trigger?
Thanks for any information
I also find it a bit confusing that CustomEmailSender
is to be defined in senders:{}
instead of triggers:{}
since this and CustomSmsSender
are lambda triggers and defined as such in all the documentation in AWS
@jamilsaadeh97
Thank you for raising this point! After reviewing the current structure and CloudFormation's requirements, I believe refactoring the KMS key configuration to reside at the LambdaConfig
level would be a more scalable and maintainable solution. Here's my reasoning:
kmsKeyArn
in LambdaConfig
?Alignment with CloudFormation:
kmsKeyArn
to be part of the LambdaConfig
, not specific to each sender. By following this convention, we can avoid potential misconfigurations and ensure compatibility with CloudFormation's structure.Simplified Configuration:
LambdaConfig
reduces redundancy and makes it easier to manage configurations. This is especially beneficial if the key is meant to serve both CustomEmailSender
and CustomSmsSender
use cases.Flexibility for Future Extensions:
kmsKeyArn
in LambdaConfig
, we create a centralized configuration point. If new senders or triggers are added in the future, they can reuse the same structure without additional changes.kmsKeyArn
is moved from CustomEmailSender
to LambdaConfig
.CustomSmsSender
to follow the same pattern, utilizing the shared kmsKeyArn
from LambdaConfig
.Here’s an example of how the updated types might look:
export type LambdaConfig = {
handler: IFunction;
kmsKeyArn?: string; // Shared KMS key for all senders
};
export type CustomEmailSender = {
handler: IFunction;
};
export type CustomSmsSender = {
handler: IFunction;
};
Environment information
Description
these values are the defineAuth method's option attributes.
there is no custom sender lambda value.
To reach that requirement, i had to custom the userPool on a phase of
amplify backend cdk
.The sample code is here.
and this is the function's handler code
I hope the
amplify backend
supply this feature officially