2

私はserverlessフレームワークを使用しており、Lambda関数で作成されたUserPoolのデフォルト値をオーバーライドする必要があります。それを行う正しい方法は何ですか?Lamda関数とリソースで同じCognito UserPoolを使用しますか?

service: userpool 

custom: 
    stage: dev 
    poolName: user-pool 

provider: 
    name: aws 
    runtime: nodejs6.10 
    stage: ${opt:stage, self:custom.stage} 

functions: 
    preSignUp: 
    handler: handler.preSignUp 
    events: 
     - cognitoUserPool: 
      pool: ${self:custom.poolName} 
      trigger: PreSignUp 

resources: 
    Resources: 
    UserPool: 
     Type: "AWS::Cognito::UserPool" 
     Properties: 
     UserPoolName: ${self:custom.poolName} 
     AliasAttributes: 
      - email 
     AutoVerifiedAttributes: 
      - email 
     Schema: 
      - Name: name 
      AttributeDataType: String 
      Mutable: true 
      Required: true 
      - Name: email 
      AttributeDataType: String 
      Mutable: false 
      Required: true 

答えて

1

https://serverless.com/framework/docs/providers/aws/guide/resources/#aws---resources

でこの形式CognitoUserPool {normalizedPoolId}を次のCognitoユーザープールリソースを作成した場合、あなたはあなたのラムダごとにnormalizedPoolIdを与えることができます機能。あなたのケースでは

は、あなたがあなたのラムダで試験プールを使用することができます「CognitoUserPool 試験プール」としてCognitoユーザープールを定義しています。

0

それが機能するようになりました、誰かがどのように私に説明することができます 私serverless.ymlは、ラムダ関数用とUserPoolリソースのための別の2つのuser-pool(同じ名前)を作成していますか?以下のコードは、Cognitoリソースとイベントで作成されたプールが同じであることをどのように認識していますか?サーバレスのドキュメントを1として

service: userpool 

custom: 
    stage: dev 

environment: 
    USER_POOL: userPool 

provider: 
    name: aws 
    runtime: nodejs6.10 
    stage: ${opt:stage, self:custom.stage} 

functions: 
    preSignUp: 
    handler: handler.preSignUp 
    events: 
     - cognitoUserPool: 
      pool: TestPool 
      trigger: PreSignUp 

resources: 
    Resources: 
    CognitoUserPoolTestPool: 
     Type: "AWS::Cognito::UserPool" 
     Properties: 
     AliasAttributes: 
      - email 
     AutoVerifiedAttributes: 
      - email 
     Schema: 
      - Name: name 
      AttributeDataType: String 
      Mutable: true 
      Required: true 
      - Name: email 
      AttributeDataType: String 
      Mutable: false 
      Required: true 
+0

スタック全体とすべてのユーザープール(CFが自動的にそれらを削除するとは思わない)を削除して再配置して、動作するようにしてください。 –

関連する問題