【发布时间】:2020-12-15 18:13:07
【问题描述】:
在注册新的 Cognito 用户之前,我创建了一个 lambda 来检查自定义逻辑。在为此 lambda 创建 IAM 策略时,我应该在这里使用什么正确的“操作”和“资源”?
拉姆达
exports.handler = function(event, context) {
// Configure the email domain that will be allowed to automatically verify.
var approvedDomain = "approveddomain.com";
// Log the event information for debugging purposes.
console.log('Received event:', JSON.stringify(event, null, 2));if (event.request.userAttributes.email.includes('@' + approvedDomain)) {
console.log ("This is an approved email address. Proceeding to send verification email.");
event.response.emailSubject = "Signup Verification Code";
event.response.emailMessage = "Thank you for signing up. " + event.request.codeParameter + " is your verification code.";
context.done(null, event);
} else {
console.log ("This is not an approved email address. Throwing error.");
var error = new Error('EMAIL_DOMAIN_ERR');
context.done(error, event);
}};
到目前为止我的最佳猜测:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "LambdaSignUp",
"Effect": "Allow",
"Action": [
"cognito-sync:*",
"cognito-idp:*",
],
"Resource": "arn:aws:cognito-idp:REGION:ACCOUNT_ID:userpool/USER_POOL_ID"
}
]
}
【问题讨论】:
标签: amazon-web-services aws-lambda amazon-cognito