我正在尝试构建一个 CloudFormation 脚本来设置 Cognito 用户池并将其配置为使用自定义电子邮件在注册过程中向用户发送其验证代码(即 FROM:noreply@mydomain.com)。
执行 AWS CloudFormation 脚本时出现此错误:
"ResourceStatusReason": "Cognito is not allowed to use your email identity (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidEmailRoleAccessPolicyException;
我附上了 Cognito 使用我的 SES 电子邮件身份的政策,例如 noreply@mydomain.com。在运行 CloudFormation 脚本之前,我已在 SES 中手动设置并验证了此电子邮件身份。
这是我的 CloudFormation 策略配置,允许 Cognito 代表我发送电子邮件,例如来自 noreply@mydomain.com:
CognitoSESPolicy:
Type: AWS::IAM::ManagedPolicy
Description: "Allow Cognito the send email on behalf of email identity (e.g. noreply@example.org)"
Properties:
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: "ucstmnt0001"
Effect: "Allow"
Action:
- "ses:SendEmail"
- "ses:SendRawEmail"
Resource: !FindInMap [ environment, !Ref "Environment", emailARN ]
SESRole:
Type: AWS::IAM::Role
Description: "An IAM Role to allow Cognito to send email on behalf of email identity"
Properties:
RoleName: uc-cognito-ses-role
ManagedPolicyArns:
- Ref: CognitoSESPolicy
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- sts:AssumeRole
Principal:
Service:
- cognito-idp.amazonaws.com
DependsOn: CognitoSESPolicy
我不确定我在这里做错了什么......