Using Custom Attributes in Amazon Cognito User Pool.

Simran Kaur Kahlon
Gray Matrix
Published in
3 min readJun 8, 2019

AWS Cognito lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily.

Cognito has two main parts to it :

  1. User Pool
  2. Identity Pool

A User Pool acts as a user directory in Cognito. With a user pool, your users can sign in to your web or mobile app through Amazon Cognito. Your users can also sign in through social identity providers like Facebook or Amazon, and through SAML identity providers

Identity pools, on the other hand, lets you create unique identities for your users and federate them with identity providers(Facebook/Google).

Cognito User Pool providers you with a lot of built-in attributes like name, phone number, email, etc.

But at times we need to add certain other values with regards to users… In my case, I used a custom attribute to keep a tab on which user is added to which group.

You could add custom attributes while creating a user pool or you could even edit the user pool to add custom attributes later.

I assume that you have a user pool created.

Adding custom attributes to your user pool :

  1. Select your user pool.
  2. On the left-hand side select Attributes as follows :

3. Scroll down to find an option for adding custom attributes as :

4. Click on add custom attribute to add one as follows:

You need to specify the following details:

  1. Type (The datatype of the attribute . You can select either as a string or int)
  2. Name
  3. Min length
  4. Max length
  5. Mutable (If you wish to allow the user to change the value of a custom attribute after the value has been provided by the user, select Mutable)

To add another custom attribute you could click on “Add another attribute” and Save Changes later.

I could very easily do this but didn’t know how to make it accessible and easily wasted an hour or so on the same.

So make sure to set permissions for your custom attributes as follows:

  1. Select App Client from the left-hand side as :

2. Click on “Set Attribute read and write permissions”, it would show up as :

3. Make sure to select your custom attribute in readable/writable attributes according to your needs, in my case its “custom:example_field”.

The custom attributes in AWS begin with a “custom:” prefix.

That’s it… Now it's available for you to use…

Please get in touch in case of any queries.

Thanks.

--

--

Simran Kaur Kahlon
Gray Matrix

JS/ Laravel / AWS / Chatbot Developer #AWS Solution Architect Associate #AWS Developer Associate