What are the pros and cons of using Cognito-id (Cognito sub) as a primary key?

0

I am currently building a Django app that uses AWS Cognito for auth.

I am having a hard time understanding the pros and cons of using Cognito-sub as the primary key for my user table versus using a generic uuid4 + cognitio_id field.

What are some edge cases that might make this a bad idea? One thing came to mind is if I accidentally deleted my Cognito User Pool it would be very hard to recover my user db.

已提問 2 年前檢視次數 423 次
1 個回答
0

Hi,

You have basically identified the primary reason not to use the Sub attribute. If you need to migrate user pools, replicate users to another region, restore expected users, etc. the sub would be different so therefore it's typically a bad idea to use it as a key. A UUID with the Cognito ID provides more protection against this. The only downside of this is that you still have to create the unique key yourself but it avoids any issues in the event you have to recover the pool.

Thanks, Owen

AWS
Owen
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南