aws-amplify / aws-amplify/amplify-cli
Imported auth has incomplete username_attributes in frontend config file
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
20
### Amplify CLI Version
12.12.4
### What operating system are you using?
Mac
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
N/A
### Describe the bug
When importing a Cognito User Pool that contains user attributes as email and phone number, the amplifyconfiguration.json file shows email only:
```
"aws_cognito_username_attributes": [
"EMAIL"
],
```
### Expected behavior
Importing auth with email and phone username attributes should include both values in frontend config output.
### Reproduction steps
Create Amplify-generated User Pool with user attributes.
```sh
amplify init
amplify add auth
a. Ensure that How do you want users to be able to sign in? Email or Phone Number is selected.
amplify push -y
```
Observe amplifyconfiguration.json as
```json
{
"aws_project_region": "us-east-1",
"aws_cognito_region": "us-east-1",
"aws_user_pools_id": "us-east-1_64iSuUnbm",
"aws_user_pools_web_client_id": "7ec82dck4mlai0bf43c5dlvupt",
"oauth": {},
"aws_cognito_username_attributes": [
"EMAIL",
"PHONE_NUMBER"
],
"aws_cognito_social_providers": [],
"aws_cognito_signup_attributes": [
"EMAIL"
],
"aws_cognito_mfa_configuration": "OFF",
"aws_cognito_mfa_types": [
"SMS"
],
"aws_cognito_password_protection_settings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": []
},
"aws_cognito_verification_mechanisms": [
"EMAIL"
]
}
```
Create another Amplify application with imported User Pool:
```sh
amplify init
amplify import auth
a. Use User Pool only (no identiity pool)
Select the Amplify-generated User Pool and client ID from the previous steps.
amplify push -y
```
Observe amplifyconfiguration.json file
```json
{
"aws_project_region": "us-east-1",
"aws_cognito_region": "us-east-1",
"aws_user_pools_id": "us-east-1_64iSuUnbm",
"aws_user_pools_web_client_id": "7ec82dck4mlai0bf43c5dlvupt",
"oauth": {},
"aws_cognito_username_attributes": [
"EMAIL"
],
"aws_cognito_social_providers": [],
"aws_cognito_signup_attributes": [
"EMAIL"
],
"aws_cognito_mfa_configuration": "OFF",
"aws_cognito_mfa_types": [],
"aws_cognito_password_protection_settings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": []
},
"aws_cognito_verification_mechanisms": [
"EMAIL"
]
}
```
Specifically noting that one has aws_cognito_username_attributes as EMAIL and the other has it set as EMAIL, PHONE_NUMBER
### Project Identifier
_No response_
### Log output
```
# Put your logs below this line
```
### Additional information
_No response_
### Before submitting, please confirm:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Contributor guide
Research direction
Reproduce the issue with `amplify import auth` and compare the generated `amplifyconfiguration.json` with the configuration from `amplify add auth`. Trace the auth import and frontend configuration generation entry points, then verify that the imported file preserves both EMAIL and PHONE_NUMBER in `aws_cognito_username_attributes`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- authentication, cli, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100