我不确定如何设置无服务器云形成资源部分的“EmailConfiguration”部分。有没有人有如何做到这一点的示例?任何指导都将不胜感激!
以下是我的 serverless.yml 文件。
service: cognito-email-config
provider:
name: aws
runtime: nodejs6.10
region: us-east-1
plugins:
- serverless-stack-output
custom:
output:
handler: serverless/output.handler
file: outputs/stack.json
functions:
preSignUp:
handler: serverless/preSignUp.handler
postConfirmation:
handler: serverless/postConfirmation.handler
resources:
Resources:
SESRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- "cognito-idp.amazonaws.com"
Action:
- "sts:AssumeRole"
Policies:
- PolicyName: "CognitoSESPolicy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "ses:SendEmail"
- "ses:SendRawEmail"
Resource: "*"
CognitoUserPool:
Type: "AWS::Cognito::UserPool"
Properties:
UserPoolName: ${env:COGNITO_USER_POOL}
EmailConfiguration:
ReplyToEmailAddress: admin@example.com
SourceArn:
Fn::GetAtt: [SESRole, Arn]
AutoVerifiedAttributes:
- phone_number
MfaConfiguration: "OPTIONAL"
SmsConfiguration:
ExternalId: ${env:COGNITO_USER_POOL}-external
SnsCallerArn:
Fn::GetAtt: [SNSRole, Arn]
Schema:
- Name: name
AttributeDataType: String
Mutable: true
Required: true
- Name: email
AttributeDataType: String
Mutable: false
Required: true
- Name: phone_number
AttributeDataType: String
Mutable: false
Required: true
运行后我得到了以下错误...
Serverless: Deployment failed!
Serverless Error ---------------------------------------
An error occurred while provisioning your stack: CognitoUserPool - Email arn does not belong to your account. (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: NotAuthorizedException; Request ID: f2b14a38-82a1-11e7-8ea0-eb271a42c298).
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless
Your Environment Information -----------------------------
OS: linux
Node Version: 8.2.1
Serverless Version: 1.20.0
ERROR: Job failed: exit code 1
我认为我没有正确使用"EmailConfiguration"的"SourceArn"; 我只是从SNS复制了下面的代码示例到SES中,并希望它能正常工作。
这里是我需要设置的AWS文档参考资源: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpool.html#cfn-cognito-userpool-emailconfiguration
这个文档对我有所帮助,但没有展示如何使用SES: https://gist.github.com/singledigit/2c4d7232fa96d9e98a3de89cf6ebe7a5