AWS Cognito 不使用我的自定义消息 lambda

AWS Cognito does not use my custom message lambda

我已经通过 Terraform 创建了一个 AWS Cognito 用户池,如下所示:

resource "aws_cognito_user_pool" "users-base" {
  name     = "users"
  provider = aws.eu-west-1

  auto_verified_attributes   = ["email"]
  username_attributes        = ["email"]

  account_recovery_setting {
    recovery_mechanism {
      name     = "verified_email"
      priority = 1
    }
    recovery_mechanism {
      name     = "verified_phone_number"
      priority = 2
    }
  }

  admin_create_user_config {
    allow_admin_create_user_only = false
  }

  email_configuration {
    email_sending_account = "DEVELOPER"
    from_email_address    = "No-reply <no-reply@acme.com>"
    source_arn            = aws_ses_email_identity.no-reply.arn
  }

  lambda_config {
    custom_message = aws_lambda_function.cognito-users-base.arn
  }
}

虽然我希望我的用户收到从 aws_lambda_function.cognito-users-base 生成的邮件(配置正确,因为它之前生成错误),但他们仍然收到根据 verification_message_template.email_message_by_link 生成的邮件,我该怎么办小姐?

编辑:我还检查了生成的 smsMessage 少于 140 个字符,emailMessage 少于 20.000。此外,当我添加一个属性时,SignUp 过程会阻塞,因此会以一种方式调用 lambda。

看起来我的 lambda 正在生成一个没有 {##Some text##} 的主体,导致生成的主体被静默丢弃。