Send user registration email - AWS Cognito federated Identities

How can I send email / start the lambda function when registering a new user?

In the "Change identifier pool" section, I found only a synchronization trigger. If I understand correctly: this works every time the user synchronizes his data ...
Is there a way to call the lambda function only for "initial" synchronization or when a specific user data set is created for the user?

enter image description here

Edit:
To be more specific: I create a user through lambdas using the JS SDK. I use developer authentication with my own oauth2 thread. I do not know how to distinguish between the user providing access, for example. via Google for the first time from someone doing it a second time. Json with a passcode seam to me ... Maybe I'm wrong.

Also, using the call getOpenIdTokenForDeveloperIdentity, I don’t know how to distinguish an identifier that is new to cognito from one already known cognito.

Edit 2: To be even more precise: I built this project: https://github.com/laardee/serverless-authentication-boilerplate/blob/master/authentication/lib/storage/usersStorage.js

. , nth time. , , ...

const saveCognito = (profile) => new Promise((resolve, reject) => {
  if (profile) {
    cognitoidentity.getOpenIdTokenForDeveloperIdentity({
      IdentityPoolId: process.env.COGNITO_IDENTITY_POOL_ID,
      Logins: {
        // profile.userId = encrypted id of the e.g. google oauth2 id
        [process.env.COGNITO_PROVIDER_NAME]: profile.userId 
      }
    }, (err, dat) => {
      if (err) {
        reject(err);
      } else {
        var list_params = {
          DatasetName: 'user-data', /* dataset name */
          IdentityId: dat.IdentityId, /* cognito id */
          IdentityPoolId: process.env.COGNITO_IDENTITY_POOL_ID
        };
        cognitosync.listRecords(list_params, function(err, data) {
          if (err) {
            reject(err); // an error occurred
          } else {

            var RecordPatches = //[Parts of the i want to write to the user]
            // SyncSessionToken is returned by the cognitosync.listRecords call
            list_params["SyncSessionToken"] = data.SyncSessionToken; 
            list_params["RecordPatches"] = RecordPatches;

            cognitosync.updateRecords(list_params, function(err, update_data) {
              if (err){
                reject(err);
              } else {
                resolve();
              }
            });
          }
        });
      }
    });
  } else {
    reject('Invalid profile');
  }
});
+4
1

, , Cognito . , , Cognito, -, "Sync Trigger". Sync , Cognito IdentityId Cognito Sync.

IdentityId Cognito Federated Identity.

:

  • IdentityPool, .
  • . , IdentityId, , , . , , .
  • , , .

, . AWS . , IAM .

, . DynamoDB ( ), IdentityId, / , , .

, AWS , .

https://aws.amazon.com/premiumsupport/

+3

Source: https://habr.com/ru/post/1664211/


All Articles