15

I have below user groups in aws cognito. Admin Member Paid member

I want to assign all user to Member user group as default when they sign up on my application so I can assign different IAM role on that user group.

How do I assign user to a user group programmatically?

Skate to Eat
  • 2,554
  • 5
  • 21
  • 53

1 Answers1

15

I found that I can use adminAddUserToGroup to add user to the specific group you have set on AWS Cognito. http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#adminAddUserToGroup-property

Skate to Eat
  • 2,554
  • 5
  • 21
  • 53
  • by any chance do you know if a lambda that makes use of that API must have permissions to a cognito pool resource or to an identity pool? – 0x6C38 Jul 01 '18 at 01:05
  • 8
    this api is non-intuitive as the user has to be already created in order to call it, I wonder if a Post confirmation lambda trigger would be better? – Jeff Voss Sep 19 '18 at 21:44
  • Post confirmation lambda trigger doesn't run if the user was created via adminCreateUser, therefore using a post confirmation hook would not work. I'm currently using postAuthentication, but my biggest issue is i'm using a SQL Database which means when the instance isn't warm, it may take longer then usually to get my user. – Travis Delly Sep 30 '19 at 17:40