This module allows Anjana Data to synchronize the users of an Amazon Cognito User Pool.
The process uses the standard AWS API (ListUsers) to periodically download the full user directory. All user attributes (standard and custom) are available for field mapping.
Part 1: Configuration in AWS (IAM User)
Anjana needs programmatic credentials (Access Key / Secret Key) with specific read permissions to access the User Pool.
Step 1: Create IAM User
-
Go to the IAM (Identity and Access Management) console in AWS.
-
Select Users > Create user.
-
Assign a name (e.g.
anjana-cognito-sync). -
Complete the creation without granting console access.
-
Go to the Security credentials tab > Access keys > Create access key.
-
Select "Local code" or "Third-party application".
-
Important: Copy and save the Access Key and the Secret Key.
Step 2: Create Permissions Policy
It is recommended to restrict access solely to the User Pool you want to synchronize.
-
On the IAM user, add an Inline Policy or create a managed policy.
-
Use the following JSON, replacing the
Resourcewith the ARN of your User Pool (or use*to grant access to all pools in the account):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CognitoReadAccess",
"Effect": "Allow",
"Action": [
"cognito-idp:ListUsers",
"cognito-idp:AdminGetUser"
],
"Resource": "arn:aws:cognito-idp:eu-west-1:123456789012:userpool/eu-west-1_AbCdEfG"
}
]
}
Part 2: Get User Pool Data
-
Go to the Amazon Cognito console.
-
Access the User Pool you want to connect.
-
In the header of the "Overview" page, copy the User Pool ID.
-
Example:
eu-west-1_XyZ123
-
-
Note the Region where it is deployed (e.g.
eu-west-1).
Part 3: Configuration in application.yml
Edit Anjana's configuration file and include the data in the security.provisioning.providers.aws-cognito section.
security:
provisioning:
providers:
aws-cognito:
# Unique key to identify this data source (e.g.: pool-clientes-externos)
pool-clientes:
# AWS Region of the User Pool
region: "eu-west-1"
# User Pool ID (obtained in Part 2)
user-pool-id: "eu-west-1_XyZ123456"
# IAM User credentials (created in Part 1)
access-key: "AKIAXXXXXXXXXXXXXXXX"
secret-key: "SECRET_KEY_XXXXXXXXXXXXXXXXXXXXXXXX"
Properties Summary
Use this table to quickly locate the values needed in the AWS console.
|
YAML Property |
Description |
Source in AWS |
|---|---|---|
|
|
Access key ID of the technical user. |
IAM > Users > Security credentials |
|
|
Access key secret. |
IAM > Users > Security credentials (Only visible when created) |
|
|
Code of the region where the service is located. |
AWS Console (Top right corner) |
|
|
Unique identifier of the directory. |
Amazon Cognito > User Pools > Overview |
Custom field mapping (field-mapping)
Anjana includes a default mapping that covers the usual cases. You can override any field by indicating the Cognito attribute key from which the value should be read. The keys are listed in order of priority: the first non-empty value is used.
Default mapping
|
Anjana Field |
Default keys (priority order) |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Available fields
Anjana exposes all Cognito user attributes (both standard and custom), so any key can be used in field-mapping.
|
Key |
Description |
|---|---|
|
|
Unique, immutable identifier of the user. |
|
|
Email address. |
|
|
|
|
|
Phone number (E.164 format, e.g. |
|
|
Full name. |
|
|
First name. |
|
|
Last name. |
|
|
Middle name. |
|
|
Nickname. |
|
|
Preferred username (login). |
|
|
Profile URL. |
|
|
Gender. |
|
|
Date of birth. |
|
|
Time zone (e.g. |
|
|
Locale setting (e.g. |
|
|
Any custom attribute of the pool (e.g. |
Configuration example
security:
provisioning:
providers:
aws-cognito:
pool-clientes:
region: "eu-west-1"
user-pool-id: "eu-west-1_XyZ123456"
access-key: "..."
secret-key: "..."
field-mapping:
# Read job title from the custom attribute 'custom:position'
title: ["custom:position", "custom:title"]
# Read department from the attribute 'custom:department'
# (there is no Anjana field for department, but it can be used as a fallback in title)
phone: ["phone_number"]