I Tried Creating a Replica of a Tokyo User Pool in Osaka Using Amazon Cognito Multi-Region Replication

I Tried Creating a Replica of a Tokyo User Pool in Osaka Using Amazon Cognito Multi-Region Replication

With Amazon Cognito multi-Region replication (MRR) now supporting more Regions, I created an Osaka replica of a Tokyo user pool. Even while INACTIVE, users created in Tokyo were readable from Osaka; once ACTIVE, tokens could be obtained at the Osaka endpoint.
2026.11.24

This page has been translated by machine translation. View original

Introduction

On November 20, 2026, it was announced that Amazon Cognito multi-Region replication (MRR) now supports additional AWS Regions.

https://aws.amazon.com/about-aws/whats-new/2026/11/cognito-mrr-opt-in-regions/

MRR is a feature that synchronizes the users and settings of a primary user pool to user pools in specified secondary Regions in near real time. In this article, I replicated a user pool in Tokyo to the Osaka Region, which is among the newly added Regions.

Added Regions

MRR was previously available in 16 commercial Regions and the AWS GovCloud (US) Regions. With this update, you can now also replicate user data to the following 16 Regions. You can choose the Regions that fit your resilience, data residency, and compliance requirements.

  • Asia Pacific (Osaka, Taipei, Hong Kong, Thailand, Malaysia, Jakarta, Hyderabad, Melbourne, New Zealand)
  • Canada West (Calgary)
  • Europe (Milan, Spain, Zurich)
  • Israel (Tel Aviv)
  • Mexico (Central)
  • Africa (Cape Town)

Test Environment

  • Primary: Tokyo (ap-northeast-1)
  • Secondary: Osaka (ap-northeast-3)
  • Osaka opt-in status: ENABLED_BY_DEFAULT (no opt-in required)
  • Feature plan: Essentials
  • User pool encryption: KMS multi-Region key (Tokyo is the primary, Osaka is the replica)
  • Issuer configuration: UPDATED
  • AWS CLI: 2.42.1

Setup Steps

MRR can be enabled only for Essentials or Plus user pools. In addition, the user pool must be encrypted with a multi-Region KMS customer managed key (CMK) that can be used in all Regions where replicas are placed. Therefore, I created the key, the user pool, and the replica, in that order.

KMS Multi-Region Key

As in the official example, the key policy allows both the cognito-idp.amazonaws.com and identitystore.amazonaws.com service principals. The full policy is as follows.

Key policy template
{
  "Id": "cognito-cmk-policy",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Allow Amazon Cognito service access",
      "Effect": "Allow",
      "Principal": {"Service": ["cognito-idp.amazonaws.com", "identitystore.amazonaws.com"]},
      "Action": ["kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKeyWithoutPlainText"],
      "Resource": "*",
      "Condition": {
        "ArnLike": {"aws:SourceArn": "arn:aws:cognito-idp:*:${ACCOUNT_ID}:userpool/*"},
        "StringEquals": {"aws:SourceAccount": "${ACCOUNT_ID}"},
        "StringLike": {"kms:EncryptionContext:aws:cognito-idp:userpool-arn": "arn:aws:cognito-idp:*:${ACCOUNT_ID}:userpool/*"}
      }
    },
    {
      "Sid": "Allow Amazon Cognito service DescribeKey access",
      "Effect": "Allow",
      "Principal": {"Service": ["cognito-idp.amazonaws.com", "identitystore.amazonaws.com"]},
      "Action": "kms:DescribeKey",
      "Resource": "*",
      "Condition": {
        "ArnLike": {"aws:SourceArn": "arn:aws:cognito-idp:*:${ACCOUNT_ID}:userpool/*"},
        "StringEquals": {"aws:SourceAccount": "${ACCOUNT_ID}"}
      }
    },
    {
      "Sid": "Allow access through Amazon Cognito DescribeKey",
      "Effect": "Allow",
      "Principal": {"AWS": "*"},
      "Action": "kms:DescribeKey",
      "Resource": "*",
      "Condition": {"StringEquals": {"kms:ViaService": "cognito-idp.${REGION}.amazonaws.com", "kms:CallerAccount": "${ACCOUNT_ID}"}}
    },
    {
      "Sid": "Allow access through Amazon Cognito crypto",
      "Effect": "Allow",
      "Principal": {"AWS": "*"},
      "Action": ["kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKeyWithoutPlainText"],
      "Resource": "*",
      "Condition": {
        "StringEquals": {"kms:ViaService": "cognito-idp.${REGION}.amazonaws.com", "kms:CallerAccount": "${ACCOUNT_ID}"},
        "StringLike": {"kms:EncryptionContext:aws:cognito-idp:userpool-arn": "arn:aws:cognito-idp:*:${ACCOUNT_ID}:userpool/*"}
      }
    },
    {
      "Sid": "Allow administrators to manage the key",
      "Effect": "Allow",
      "Principal": {"AWS": "arn:aws:iam::${ACCOUNT_ID}:root"},
      "Action": "kms:*",
      "Resource": "*"
    }
  ]
}

I replaced ${ACCOUNT_ID} and ${REGION} with actual values, and saved the Tokyo one as policy-ap-northeast-1.json and the Osaka one as policy-ap-northeast-3.json.

The user pool ARN specified in Condition is arn:aws:cognito-idp:*:${ACCOUNT_ID}:userpool/*. Because the Region and user pool ID are wildcards, it matches all user pools in all Regions within the account.

I created the key in Tokyo and its replica key in Osaka. <KEY_ID> is the KeyId included in the response of create-key.

aws kms create-key --region ap-northeast-1 --multi-region --description <説明> --policy file://policy-ap-northeast-1.json

aws kms replicate-key --region ap-northeast-1 --key-id <KEY_ID> --replica-region ap-northeast-3 --policy file://policy-ap-northeast-3.json

User Pool

I created a user pool in Tokyo, specifying ESSENTIALS for the feature plan, the multi-Region key for encryption, and UPDATED for the issuer. <KMS_KEY_ARN> is the ARN of the Tokyo key. I also created an app client and a test user alice, which are used later for authentication verification.

aws cognito-idp create-user-pool --region ap-northeast-1 --pool-name mrr-verify-1121 --user-pool-tier ESSENTIALS --key-configuration KeyType=CUSTOMER_MANAGED_KEY,KmsKeyArn=<KMS_KEY_ARN> --issuer-configuration Type=UPDATED --policies 'PasswordPolicy={MinimumLength=8,RequireUppercase=false,RequireLowercase=false,RequireNumbers=false,RequireSymbols=false}' --username-attributes email --admin-create-user-config AllowAdminCreateUserOnly=true

aws cognito-idp create-user-pool-client --region ap-northeast-1 --user-pool-id <USER_POOL_ID> --client-name mrr-verify-client --no-generate-secret --explicit-auth-flows ALLOW_USER_PASSWORD_AUTH ALLOW_REFRESH_TOKEN_AUTH

aws cognito-idp admin-create-user --region ap-northeast-1 --user-pool-id <USER_POOL_ID> --username alice@example.com --message-action SUPPRESS --user-attributes Name=email,Value=alice@example.com Name=email_verified,Value=true

aws cognito-idp admin-set-user-password --region ap-northeast-1 --user-pool-id <USER_POOL_ID> --username alice@example.com --password <PASSWORD> --permanent

Replica

I created a replica of the Tokyo user pool in Osaka.

aws cognito-idp create-user-pool-replica --region ap-northeast-1 --user-pool-id <USER_POOL_ID> --region-name ap-northeast-3
{
    "UserPoolReplica": {
        "RegionName": "ap-northeast-3",
        "Status": "CREATING",
        "Role": "SECONDARY",
        "UserPoolArn": "arn:aws:cognito-idp:ap-northeast-3:111122223333:userpool/ap-northeast-1_EXAMPLE"
    }
}

In the user guide's example response, the top-level key name is Replica and the status value is PENDING_CREATE, but the actual response had UserPoolReplica and CREATING, respectively.

The status can be retrieved with list-user-pool-replicas. When I polled at roughly 10-second intervals, the Osaka replica was CREATING at 4 minutes 38 seconds after creation started, and had become INACTIVE at 4 minutes 49 seconds. This duration is a value measured only once.

aws cognito-idp list-user-pool-replicas --region ap-northeast-1 --user-pool-id <USER_POOL_ID>
{
    "UserPoolReplicas": [
        {
            "RegionName": "ap-northeast-1",
            "Status": "ACTIVE",
            "Role": "PRIMARY",
            "UserPoolArn": "arn:aws:cognito-idp:ap-northeast-1:111122223333:userpool/ap-northeast-1_EXAMPLE"
        },
        {
            "RegionName": "ap-northeast-3",
            "Status": "INACTIVE",
            "Role": "SECONDARY",
            "UserPoolArn": "arn:aws:cognito-idp:ap-northeast-3:111122223333:userpool/ap-northeast-1_EXAMPLE"
        }
    ]
}

Verification

Synchronization While INACTIVE

An INACTIVE replica can use only a limited set of read and configuration APIs. I specified the Osaka Region and retrieved the configuration of the user pool created in Tokyo.

aws cognito-idp describe-user-pool --region ap-northeast-3 --user-pool-id <USER_POOL_ID> --query 'UserPool.{Id:Id,Name:Name,UserPoolTier:UserPoolTier,Issuer:IssuerConfiguration,Key:KeyConfiguration.KeyType,MinLen:Policies.PasswordPolicy.MinimumLength,Admin:AdminCreateUserConfig.AllowAdminCreateUserOnly}'
{
    "Id": "ap-northeast-1_EXAMPLE",
    "Name": "mrr-verify-1121",
    "UserPoolTier": "ESSENTIALS",
    "Issuer": {
        "Type": "UPDATED"
    },
    "Key": "CUSTOMER_MANAGED_KEY",
    "MinLen": 8,
    "Admin": true
}

The Osaka replica could be referenced with the same user pool ID as Tokyo, and the retrieved settings matched the values specified in Tokyo.

Next, I retrieved from Osaka the user alice, which had been created in Tokyo before the replica was created.

aws cognito-idp admin-get-user --region ap-northeast-3 --user-pool-id <USER_POOL_ID> --username alice@example.com --query '{Username:Username,UserStatus:UserStatus,Enabled:Enabled,Attrs:UserAttributes[?Name!=`sub`]}'
{
    "Username": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "UserStatus": "CONFIRMED",
    "Enabled": true,
    "Attrs": [
        {
            "Name": "email",
            "Value": "alice@example.com"
        },
        {
            "Name": "email_verified",
            "Value": "true"
        }
    ]
}

I had set alice's password in Tokyo with --permanent, and the UserStatus was CONFIRMED in Osaka as well.

I then checked whether changes made in Tokyo after the replica was created are synchronized to Osaka even while it remains INACTIVE. In Tokyo, I created a user bob and a second app client.

aws cognito-idp admin-create-user --region ap-northeast-1 --user-pool-id <USER_POOL_ID> --username bob@example.com --message-action SUPPRESS --user-attributes Name=email,Value=bob@example.com Name=email_verified,Value=true

aws cognito-idp create-user-pool-client --region ap-northeast-1 --user-pool-id <USER_POOL_ID> --client-name mrr-verify-client-2 --no-generate-secret

Next, I retrieved the lists of users and app clients in Osaka.

aws cognito-idp list-users --region ap-northeast-3 --user-pool-id <USER_POOL_ID>

aws cognito-idp list-user-pool-clients --region ap-northeast-3 --user-pool-id <USER_POOL_ID>

The lists retrieved in Osaka about 2 seconds after bob was created included bob and mrr-verify-client-2, as well as alice and mrr-verify-client, which existed before the replica was created. Because the data was already synchronized at the first retrieval, the synchronization time was within about 2 seconds.

Authentication While ACTIVE

To use authentication APIs such as InitiateAuth, the replica must be ACTIVE. I changed the Osaka replica to ACTIVE.

aws cognito-idp update-user-pool-replica --region ap-northeast-1 --user-pool-id <USER_POOL_ID> --region-name ap-northeast-3 --status ACTIVE
{
    "UserPoolReplica": {
        "RegionName": "ap-northeast-3",
        "Status": "ACTIVE",
        "Role": "SECONDARY",
        "UserPoolArn": "arn:aws:cognito-idp:ap-northeast-3:111122223333:userpool/ap-northeast-1_EXAMPLE"
    }
}

The status retrieved with list-user-pool-replicas about 2 seconds later was also ACTIVE.

I called InitiateAuth by specifying the Osaka Region endpoint and obtained tokens for alice. The following script does not display the token bodies, and outputs only a summary of the result and the iss, aud, and token_use of the ID token. jq is required to run it.

initiate-auth-claims.sh
#!/usr/bin/env bash
# usage: initiate-auth-claims.sh <region> <client-id> <username> <password>
# Do not output the token bodies; display only the metadata and the iss / aud / token_use of the ID token
set -euo pipefail
REGION=$1; CLIENT=$2; USERNAME=$3; PASSWORD=$4
RES=$(aws cognito-idp initiate-auth --region "$REGION" --auth-flow USER_PASSWORD_AUTH \
  --client-id "$CLIENT" --auth-parameters "USERNAME=$USERNAME,PASSWORD=$PASSWORD")
echo "$RES" | jq '.AuthenticationResult | {TokenType, ExpiresIn, HasIdToken: (.IdToken != null), HasAccessToken: (.AccessToken != null), HasRefreshToken: (.RefreshToken != null)}'
ID=$(echo "$RES" | jq -r '.AuthenticationResult.IdToken' | cut -d. -f2)
# base64url -> base64
PAD=$(( (4 - ${#ID} % 4) % 4 )); ID="$ID$(printf '%*s' "$PAD" '' | tr ' ' '=')"
echo "$ID" | tr '_-' '/+' | base64 -d 2>/dev/null | jq '{iss, aud, token_use}'

<CLIENT_ID> is the ClientId of mrr-verify-client, which was created first.

./initiate-auth-claims.sh ap-northeast-3 <CLIENT_ID> alice@example.com <PASSWORD>
{
  "TokenType": "Bearer",
  "ExpiresIn": 3600,
  "HasIdToken": true,
  "HasAccessToken": true,
  "HasRefreshToken": true
}
{
  "iss": "https://issuer-cognito-idp.ap-northeast-1.amazonaws.com/ap-northeast-1_EXAMPLE",
  "aud": "1example23456789",
  "token_use": "id"
}

The iss of the ID token obtained at the Osaka endpoint was a URL containing the Tokyo Region code ap-northeast-1.

Summary

Amazon Cognito multi-Region replication, released in June 2026, now supports the Osaka Region, making it possible to build a configuration between Tokyo and Osaka that is completed within Japan.

https://dev.classmethod.jp/articles/amazon-cognito-multi-region-replication-tokyo-virginia/

If you want to improve the availability of your Tokyo Cognito environment for workloads where regulations such as guidelines require everything to be completed within Japan, try using the newly added Osaka Region as the replication destination.

References

Share this article

AWSのお困り事はクラスメソッドへ