2017-08-16 15 views
2

serverless cloudformationリソースセクションの "EmailConfiguration"部分の設定方法がわかりません。誰かがこれを行う方法の例がありますか?どんな指導も大歓迎です!aws cognitoユーザープールの電子メール設定を設定するにはどうすればよいですか?

ここは私の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: [email protected] 
      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

答えて

3

私はちょうど通過しました同じ試練をし、ついにそれを理解した。 AWSにはこれに関する恐ろしい文書があります。私の経験を共有して、あなたや他の人たちをうまく助けることができます。

1.)あなたはSESで送信したい電子メールを確認する必要があります。

2)電子メールを確認したら、SESダッシュボードでそのIDをクリックして、ID ARN(例:arn:aws:ses:us-west-2:MY-AWS-ACCOUNT- NUMBER:identity/[email protected])。このIdentity ARNは、上記のCloudFormationでSourceConNのEmailConfigurationで使用するものです。

3.)SESダッシュボードで確認済みの電子メールをクリックすると、IDポリシーを設定するオプションが表示されます。このスニペットをここに追加します(下のリソースARNを手順2で取得した正しいID ARNに置き換えてください):

{ 
    "Version": "2008-10-17", 
    "Statement": [ 
     { 
      "Sid": "stmnt1234567891234", 
      "Effect": "Allow", 
      "Principal": { 
       "Service": "cognito-idp.amazonaws.com" 
      }, 
      "Action": [ 
       "ses:SendEmail", 
       "ses:SendRawEmail" 
      ], 
      "Resource": "arn:aws:ses:us-west-2:<MY-AWS-ACCOUNT-NUMBER>:identity/[email protected]" 
     } 
    ] 
} 
関連する問題