Mapping Cognito Identity Id and User Pool Id


#1

Link to chapter - http://serverless-stack.com/chapters/mapping-cognito-identity-id-and-user-pool-id.html


#2

What will be the usage of the UserPool User Id inside the lambda?

I’ve trying to store some user data that wanted to retrieve inside Lambda and couldn’t figure out how to do it and ended up with a dynamodb table that has stored the CognitoIdentityId as a way to retrieve that data.

If this chapter is a solution to my problem I don’t see which part of the JS sdk I have to use inside the lambda to access the user pool.


#3

I think it’s useful for looking up user attributes for instance, if you wanted a subscription/follow feature between users. It appears to me to open up your userpool to be more like a dynamoDB table you can query.


#4

It seems so but unfortunately I could find what part of the JS sdk let’s you get that information. Maybe @jayair could give us a hint about what was the meaning of that chapter.


#5

Yeah the basic problem is that when you authenticate your Lambda functions with IAM, you only get the Identity Id to work with. But there is no way to get the User Pool Id given the Identity Id. But this chapter details a little trick to let you get that.

You could then use that to get info using the Admin Cognito User Pool - https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminGetUser.html.