Create the Identity Pool
Last updated
Last updated
Now, our application is ready but does not have any AWS credentials to use any of the AWS services directly. To allow our application to use AWS services like S3, we will need to configure an Identity pool and assign a role with an authenticated user.
Go to the Federated identities
from the top-left section in Cognito console
Select Create new identity pool
Give the identity pool name
Open the Authentication providers
section
Here we will configure the source of our user data, in our case, it would be a Cognito User Pool that we previously created.
Copy the User Pool ID
and App client id
from the app-config.js configuration here
Continue the setup with Create Pool
Now we will need to attach the IAM Roles
to our Identity pool. You will see two roles, one for Authenticated and the next one for Unauthenticated users.
Authenticated users are those who have a valid Cognito user pool session after doing the sign-in, and Unauthenticated users are those who are yet to either signup or has a valid user but not yet signed in.
We will keep this to default and complete the setup with Allow
command at the bottom
Copy the Identity pool id
and save to app-config.js
Now our app contains both the Cognito user pool and the Cognito identity pool. Move the current changes to the S3 bucket and reload the app. If you are already signed-in then the log should show the token and expiry detail.
Reload the application now and it should work.