amplify-cli
amplify-cli copied to clipboard
fetchUserAttributes() throws an error ResourceNotFoundException: IdentityPool 'us-west-1:xxx-xxx-xxx' not found.
Before opening, please confirm:
- [X] I have searched for duplicate or closed issues and discussions.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React
Amplify APIs
Authentication, GraphQL API
Amplify Version
v6
Amplify Categories
auth
Backend
Amplify CLI
Environment information
# Put output below this line
System:
OS: macOS 14.2.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 167.40 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
Yarn: 1.5.1 - /usr/local/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
Browsers:
Chrome: 120.0.6099.234
Safari: 17.2.1
npmPackages:
@aws-amplify/ui-react: ^6.0.6 => 6.0.6
@aws-amplify/ui-react-internal: undefined ()
@cloudscape-design/components: ^3.0.465 => 3.0.465
@cloudscape-design/global-styles: ^1.0.20 => 1.0.20
@storybook/addon-essentials: ^7.6.5 => 7.6.5
@storybook/addon-interactions: ^7.6.5 => 7.6.5
@storybook/addon-links: ^7.6.5 => 7.6.5
@storybook/addon-onboarding: ^1.0.10 => 1.0.10
@storybook/blocks: ^7.6.5 => 7.6.5
@storybook/react: ^7.6.5 => 7.6.5
@storybook/react-vite: ^7.6.5 => 7.6.5
@storybook/test: ^7.6.5 => 7.6.5
@types/react: ^18.2.43 => 18.2.45
@types/react-dom: ^18.2.17 => 18.2.18
@vitejs/plugin-react-swc: ^3.5.0 => 3.5.0
aws-amplify: ^6.0.7 => 6.0.7
aws-amplify/adapter-core: undefined ()
aws-amplify/analytics: undefined ()
aws-amplify/analytics/kinesis: undefined ()
aws-amplify/analytics/kinesis-firehose: undefined ()
aws-amplify/analytics/personalize: undefined ()
aws-amplify/analytics/pinpoint: undefined ()
aws-amplify/api: undefined ()
aws-amplify/api/server: undefined ()
aws-amplify/auth: undefined ()
aws-amplify/auth/cognito: undefined ()
aws-amplify/auth/cognito/server: undefined ()
aws-amplify/auth/server: undefined ()
aws-amplify/datastore: undefined ()
aws-amplify/in-app-messaging: undefined ()
aws-amplify/in-app-messaging/pinpoint: undefined ()
aws-amplify/push-notifications: undefined ()
aws-amplify/push-notifications/pinpoint: undefined ()
aws-amplify/storage: undefined ()
aws-amplify/storage/s3: undefined ()
aws-amplify/storage/s3/server: undefined ()
aws-amplify/storage/server: undefined ()
aws-amplify/utils: undefined ()
eslint: ^8.55.0 => 8.56.0
eslint-plugin-react: ^7.33.2 => 7.33.2
eslint-plugin-react-hooks: ^4.6.0 => 4.6.0
eslint-plugin-react-refresh: ^0.4.5 => 0.4.5
eslint-plugin-storybook: ^0.6.15 => 0.6.15
plop: ^4.0.1 => 4.0.1
plop-example: undefined ()
plop-example-action-failure: undefined ()
plop-example-add-action: undefined ()
plop-example-prompts-only: undefined ()
plop-example-wrap: undefined ()
prop-types: ^15.8.1 => 15.8.1
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
react-router-dom: ^6.21.0 => 6.21.0
storybook: ^7.6.5 => 7.6.5
vite: ^5.0.8 => 5.0.10
npmGlobalPackages:
@aws-amplify/cli: 12.10.0
corepack: 0.22.0
npm: 10.2.3
Describe the bug
I've added name as a standard attribute in Cognito sign up user pool and have set read/write permissions properly.
When a user registers, the name value (when selected) appears in the Cognito console.
However, when I call getCurrentUser(), the only properties in the object are userId, username, and signInDetails. signInDetails contains a loginId and an authFlowType.
I would like the front end React app to have access to the standard name attribute. Documentation here seems to indicate that using fetchUserAttributes() will provide this data.
However, I get this error in my console:
I do not use identity pools. I am trying to get a standard attribute from a user pool.
Expected behavior
When calling fetchUserAttributes(), the method should return an object containing any standard or custom attributes in my Cognito user pool.
Reproduction steps
- Set up Cognito to use one or more standard attributes like name, given name, family name, etc. in your user pool.
- Confirm in the AWS console that Cognito has captured this data in your user pool on Sign Up.
- Use fetchUserAttributes() in your front end code to try to retrieve the values of these standard attributes.
Code Snippet
// Put your code below this line.
import { getCurrentUser, fetchUserAttributes } from "aws-amplify/auth";
const getUserData = async () => {
try {
const currentUser = await getCurrentUser();
console.log("currentUser", currentUser); // this logs an object with a userId and username. No attributes are included.
const attributes = await fetchUserAttributes(); // <-- This line throws an error
console.log("attributes", attributes);
} catch (error) {
console.log("error", error);
}
};
Log output
// Put your logs below this line
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
hello @mark-carlson , can you try upgrading amplify to the latest version and see if you still experience this issue ?
Also just in case, you will get an exception if you are passing an invalid identityPoolId
in your config, if you are not using identity pools, try to avoid including one.
Hi @israx . I can confirm I am on the latest version of amplify and have no identityPoolId in my config. After updating to v6.0.13, I still have this issue.
By the way, I would also be happy if getCurrentUser()
returned any existing standard attributes.
I'm able to reproduce this issue when I have an invalid identity pool in the config, once I remove it, it works as expected. Can you share your amplify configuration without showing any sensitive information ?
Yeah returning standard attributes from getCurrentUser()
should be a feature request for now. If you want you could open a new GitHub issue so we can triage it accordingly
Thank you, @israx. I can confirm that I did indeed have an identity-pool-id in my config. One of them was in an auto-generated file aws-exports.js
. I removed it manually. Is there a way to remove this entry with amplify-cli?
did you try running amplify auth remove ?
did you try running amplify auth remove ?
I did not. Was afraid of throwing out the baby with the bathwater. But that would be a valid way to start fresh, I guess. Thank you again for pointing out the cause and solution!
I have the same problem. I tried removing and recreating the auth, rebuilding the lambda trigger, resetting permissions, and still have the same problem. It seems to get better if I manually delete the aws_cognito_identity_pool_id from my local amplifyconfiguration.json, but how did it get there? This file gets generated from something, doesn't it?
@jkellyinsf, this problem has happened repeatedly for me since I closed the issue. Everytime it happens, I go through searching for identity pool ids to remove from my configs.
Hi @mark-carlson due to this consistently happening, I'll re-open this issue and mark it as a bug and discuss it with the team. I will follow up with updates asap.
Hey @mark-carlson, had a quick question, was the identity pool created by Amplify CLI removed on the AWS Cognito console?
we can just create a user pool without an identity pool, by utilizing the following on update/add auth on the following option.
Do you want to use the default authentication and security configuration? Manual configuration
Select the authentication/authorization services that you want to use: User Sign-Up & Sign-In only (Best used with a cloud API only)
On each push/pull amplify regenerates the amplifyconfiguration.json
or aws-exports.js
files
I ran into this as well and can confirm that removing the aws_cognito_identity_pool_id
line from my amplifyconfiguration.json seems to have fixed it.
Closing the issue due to inactivity. Do reach out to us if you are still experiencing this issue
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.