amplify-js: "Invalid identity pool configuration. Check assigned IAM roles for this pool."
Describe the bug It appears the AWS SDK is not being configured correctly.
I was adding storage to my app but I kept getting 403 errors every time I tried to upload. After some digging I tried calling Auth.currentUserCredentials, which returns the following error:
InvalidIdentityPoolConfigurationException: Invalid identity pool configuration. Check assigned IAM roles for this pool.
In the console I have checked the IAM roles and user pool and they are configured correctly, so I assume the issue lies in how the config is being handled.
To Reproduce Steps to reproduce the behavior:
amplify initamplify add authamplify add storage(allow authenticated users to read, create and update. Unauthenticated users allowed to read only)- Create a user
- Log in as user
- Attempt to upload an image with
Storage.put - See 403 error
- Call
Auth.currentUserCredentials - See
InvalidIdentityPoolConfigurationExceptionerror
Expected behavior I should be able to authenticate and upload files using the AWS SDK as documented in the official documentation: https://docs.amplify.aws/lib/storage/upload/q/platform/js
Code Snippet Inside any handler:
onPress={() => Storage.put('user/avatar', blob)}
Inside any component:
React.useEffect(() => {
Auth.currentUserCredentials().then(console.log);
}, []);
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (5 by maintainers)
Thanks @Amplifiyer
I can confirm it’s an issue with how
Amplify.configurehandles theaws-exports.jsfile. Hopefully we can get this issue resolved before long (I’m happy to help), will also save other people time if this is mentioned in the docs while a fix is being worked on.I was able to workaround the issue by manually applying the properties from
aws-exports.jstoAmplify.configure:I ran into this error but it wasn’t to do with the
authRoleas listed above. Mine was because I had manually created a group on Cognito and then was using that group and its associated role with some users. I wanted to document what I did in case anyone gets to this point and isn’t able to solve the problem.TL;DR: Don’t manually create groups and roles if you’re going to be using them for Amplify.
What I did to find out what the role that was causing the issue was to take the
access_tokenthat gets returned on thePOSTrequest to AWS. You can take this token and plug it into https://jwt.io/ which will decode it.My issue was that any account where I was getting the above error included the following attributes in that JWT
If you are getting this issue, find these roles and verify that they have the conditions attached to them from @timoteialbu’s response:
"Condition": { "StringEquals": { "cognito-identity.amazonaws.com:aud": "us-west-2:<COGNITO_IDENTITY_POOL_ID>" }, "ForAnyValue:StringLike": { "cognito-identity.amazonaws.com:amr": "authenticated" } }My solution was to just manually delete the group I’d created along with the role associated with it and then recreate it via the Amplify CLI and then just move all the users who were in the original group into the new one. This way Amplify maintains it when it changes.
I found a way to solve my issue regarding the
InvalidIdentityPoolConfigurationException: Invalid identity pool configuration. Check assigned IAM roles for this pool.error.The solution was to look up the
authRolethat amplify-cli creates and add trust relationships. Here is what I edited it to:Since this was working before June 2020 (which was the last time we successfully created a new env and had it working with no extra changes like this), what has changed since? I looked through the changelog but could not find anything.
Are we supposed to add trust relationships ourselves?
I just upgraded to the latest version of these packages:
and the issue persists.
I have the same issue and changing the export file does not solve it.