I am using a single table to store all my data in dynamodb as such:
| Partion Key (PK) | Sorting Key (SK) | Attributes |
|---|---|---|
| USER#gijoe | PROFILE#gijoe | { name: "G.I", lastName: "Joe" } |
| USER#gijoe | CARD#first-card | { name: "King", picture: "./king.png" } |
I am using the preferred_username as a part of the Partition Key, and thus need it to be unique to avoid colliding user data.
How can I garantee that two users in my User Pool cannot have matching preferred_username ?
Edit:
The answer from @Lukas did it. Note that it required me to drop and recreate my cloudformation stack, which is why it failed on my first tries. Now when I try to edit the preferred_username I get the error I was looking for:
{
"message": "Already found an entry for the provided username.",
"code": "AliasExistsException",
"time": "2021-01-19T09:36:47.874Z",
"requestId": "7b52dbc2-58c5-4354-aa51-66d4dc7472a0",
"statusCode": 400,
"retryable": false,
"retryDelay": 85.84051584672932
}