Closed mitchelllee222 closed 2 months ago
Hey @mitchelllee222 :wave: thanks for raising this! While we work to improve our API documentation the attributes listed in this object are camelCase and align with CDK's StandardAttributes
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.StandardAttributes.html#properties
Thank you! I updated the attributes to use fullname and phoneNumber as listed in the doc you listed and was able to get past the previous issue. However, this introduced a new issue in which now it says that I can't update the userpool that was already created: 90
2024-07-02T19:05:20.571Z [INFO]: CFNUpdateNotSupportedError: User pool attributes cannot be changed after a user pool has been created.
91
Resolution: To change these attributes, remove defineAuth
from your backend, deploy, then add it back. Note that removing defineAuth
and deploying will delete any users stored in your UserPool.
I apologize, but I am not following what the Resolution is telling me to do to resolve this. I had no control over the initial creation of the UserPool and I'm okay with the warning about it deleting any users since I'm just setting up the app, but I'm not sure how I update the resource.ts file appropriately to make the changes.
Hey @mitchelllee222 this is a Cognito limitation where required
attributes cannot be changed after initial creation https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#how-to-edit-standard-attributes
To delete it you can comment out/remove the auth
resource from defineBackend
, push to git to allow it to deploy, then add it back
import { defineBackend } from "@aws-amplify/backend"
import { auth } from "./auth/resource"
import { data } from "./data/resource"
defineBackend({
- auth,
data,
})
Thank you Jose, now that I have some clearer understanding how gen 2 works, I just deleted the app, updated the resource.ts in Auth to correctly have the attributes I want and created the app again. Now I'm off to the races with the correct properties defined in project using the property names from the doc you shared.
Environment information
Description
I'm in the process of converting my gen 1 app to a gen 2 app. I'm attempting to setup authentication. My app previously used Cognito with email to log in, but also required user to provide name and phone_number attributes. I configured my resource.ts as such:
`import { defineAuth } from "@aws-amplify/backend"
export const auth = defineAuth({ loginWith: { email: true, }, userAttributes: { name: { mutable: true, required: true, }, phone_number: { mutable: true, required: true, }, }, }) ` According to the gen 2 documentation, userAttributes can be used to define any standard Cognito attributes, which name and phone_number are both standard attributes. However, when it goes to compile, I get this error:
2024-07-02T04:12:28.597Z [INFO]: amplify/auth/resource.ts(8,5): error TS2353: Object literal may only specify known properties, and 'name' does not exist in type 'StandardAttributes'.
Followed documentation from: https://docs.amplify.aws/react/build-a-backend/auth/concepts/user-attributes/ Which links to list of standard attributes: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#cognito-user-pools-standard-attributes