---
title: How to Deploy Logto as an AWS Cognito Alternative
url: https://docs.vultr.com/how-to-deploy-logto-as-an-aws-cognito-alternative
description: Deploy Logto on a Linux server using Docker Compose with PostgreSQL and Traefik for automatic HTTPS, as a self-hosted CIAM alternative to AWS Cognito.
publish_date: 2026-09-09T03:31:21.877637Z
last_updated: 2026-09-24T20:55:21.091607Z
author: Sachin Pandey
header_image: https://lhr1.vultrobjects.com/docs-main-doc-assets-1/2670/a23af88e-7d01-42f4-bd0b-0f6b058f574c.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

[AWS Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/what-is-amazon-cognito.html) is Amazon's managed authentication service for web and mobile applications. It provides User Pools for user directories, Identity Pools for federated access to AWS resources, a hosted managed login UI, Lambda triggers for inline customization, and passwordless sign-in, packaged across Lite, Essentials, and Plus feature tiers. It removes the need to operate an identity store, but it bills per monthly active user (MAU) beyond a free tier of 10,000 MAU that applies only to the Lite and Essentials tiers, gates threat protection and risk-based adaptive authentication behind the Plus tier, which has no free tier at all, and ties the user directory, its customization hooks, and federated resource access to AWS regions, Lambda, and Identity and Access Management (IAM).

[Logto](https://logto.io/) is an open-source Customer Identity and Access Management (CIAM) platform built on the OAuth 2.1 and OpenID Connect (OIDC) standards, and it covers the same ground on self-hosted infrastructure without per-user billing or cloud provider API dependencies. It provides a branded sign-in experience, social and enterprise Single Sign-On (SSO) federation, multi-factor authentication (MFA), role-based access control (RBAC), organizations for multi-tenancy, and webhooks, and it stores every user, application, and role in a PostgreSQL database you control. Because it implements the OIDC specification rather than a proprietary protocol, standard client libraries integrate with it unchanged. A self-hosted deployment also gives you direct control over the token lifetimes, the user schema, the connector set, and the data residency of the identity store.

This article explains how to deploy Logto as an alternative to AWS Cognito. It covers the Docker Compose deployment with Traefik as the reverse proxy, automatic HTTPS with Let's Encrypt, the admin console, the sign-in experience and brand identity, email and social login connectors, enterprise SSO, MFA, RBAC and API resources, organizations for multi-tenancy, application registration, webhooks, deployment verification, and migration from AWS Cognito.

## Understanding Logto Architecture

Logto covers most AWS Cognito components through a self-hosted, OIDC-standard platform. The following table maps each Cognito feature to its Logto counterpart and notes where no equivalent exists.

| AWS Cognito | Logto | Description |
|-------------|-------|-------------|
| Cognito User Pools | Logto Users + Sign-in Experience | User management and hosted login pages. |
| Cognito User Pool SAML and OIDC identity providers | Logto Enterprise SSO Connectors (SAML/OIDC) | Federation with external identity providers. |
| Cognito Identity Pools | No direct equivalent | Grants access to AWS resources through IAM roles. |
| Cognito Hosted UI | Logto Sign-in Experience | Fully customizable branded authentication flow. |
| Cognito Social Providers | Logto Social Connectors | Integration with over 30 social identity providers. |
| Cognito MFA (SMS, TOTP) | Logto MFA | TOTP, WebAuthn/Passkeys, SMS, Email OTP, and backup codes. |
| Cognito Lambda Triggers | Logto Webhooks | Asynchronous event-driven webhooks (not inline). |
| Cognito App Clients | Logto Applications | OIDC clients for SPAs, web apps, and M2M services. |
| Cognito Groups | Logto Roles + Organizations | Role-based access control and multi-tenant management. |
| Cognito Advanced Security | No direct equivalent | Use WAF, rate limiting, or a reverse proxy for protection. |
| AWS Amplify SDKs | Logto SDKs | Official SDKs for over 30 modern development frameworks. |

The Logto Core service (`auth.example.com`) exposes the OIDC endpoints, Management API (`/api`), and the user-facing sign-in experience. The Admin Console (`admin.example.com`) is a separate frontend that manages tenant configuration through the Management API.

## Prerequisites

Before you begin, you need to:

* Have access to a [Linux-based server](https://docs.vultr.com/products/compute/cloud-compute/provisioning) (with at least 2 CPU cores and 4 GB of RAM) as a [non-root user with sudo privileges](https://docs.vultr.com/how-to-create-a-sudo-user-in-linux).
* [Install Docker and Docker Compose](https://docs.vultr.com/how-to-install-docker-on-ubuntu-24-04#install-docker).
* Create [DNS A records](https://docs.vultr.com/products/network/dns/management/manage-records) pointing to your server's IP address for the following subdomains: `auth.example.com` (Logto Core API and sign-in experience) and `admin.example.com` (Admin Console).

## Deploy Logto with Docker Compose

Logto requires PostgreSQL 14 or later to store users, configuration, and session data. This section deploys Logto for production on a Linux server using Docker Compose, Traefik for automatic HTTPS with Let's Encrypt, and PostgreSQL for durable storage.

1. Create the project directory structure.

    ```console
    $ mkdir -p ~/logto/traefik/letsencrypt
    ```

1. Navigate to the project directory.

    ```console
    $ cd ~/logto
    ```

1. Create the Logto environment file.

    ```console
    $ nano .env
    ```

    Add the following configuration:

    ```ini
    # Domain Configuration
    LOGTO_CORE_DOMAIN=auth.example.com
    LOGTO_ADMIN_DOMAIN=admin.example.com

    # Logto Endpoints
    ENDPOINT=https://auth.example.com
    ADMIN_ENDPOINT=https://admin.example.com

    # SSL Configuration
    LETSENCRYPT_EMAIL=admin@example.com

    # Database
    DB_PASSWORD=DB-PASSWORD

    # Logto image version
    TAG=1.40.1

    # Pins the Docker Engine API version to avoid socket communication errors with newer Traefik releases
    DOCKER_API_VERSION=1.54
    ```

    Save and close the file.

    Replace:

    * `auth.example.com`: Your Logto Core API subdomain.
    * `admin.example.com`: Your Admin Console subdomain.
    * `admin@example.com`: Your email address for Let's Encrypt certificate notifications.
    * `DB-PASSWORD`: A strong password for the PostgreSQL database.
    * `1.40.1`: The Logto release version to deploy. Check the [Logto releases](https://github.com/logto-io/logto/releases) page for the latest stable version when upgrading.

1. Download the Logto Docker Compose file for the pinned release.

    > [!NOTE]
    > Pin the compose file URL to the same release tag as `TAG` in the environment file. The following `docker-compose.yml` file is maintained by Logto.

    ```console
    $ wget https://raw.githubusercontent.com/logto-io/logto/v1.40.1/docker-compose.yml
    ```

1. Update the `docker-compose.yml` file for production use. The official compose file ships with hardcoded database credentials and is labeled for demonstration; replace those defaults before deployment.

    ```console
    $ nano docker-compose.yml
    ```

    Find the `app` service and update the `DB_URL` under the `environment` section as follows:

    ```yaml
    - DB_URL=postgres://postgres:${DB_PASSWORD}@postgres:5432/logto
    ```

    Find the `postgres` service and update the `POSTGRES_PASSWORD` value in the `environment` section:

    ```yaml
    POSTGRES_PASSWORD: ${DB_PASSWORD}
    ```

    Pin the PostgreSQL image to a specific release for reproducible deployments:

    ```yaml
    image: postgres:17.5-alpine
    ```

    Save and close the file.

1. Create the Traefik Docker Compose override file.

    ```console
    $ nano traefik/docker-compose.yml
    ```

    Add the following configuration:

    ```yaml
    services:
      traefik:
        image: traefik:v3.7.0
        command:
          - "--providers.docker=true"
          - "--providers.docker.exposedbydefault=false"
          - "--entrypoints.web.address=:80"
          - "--entrypoints.websecure.address=:443"
          - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
          - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
          - "--certificatesresolvers.myresolver.acme.email=${LETSENCRYPT_EMAIL}"
          - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
          - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
          - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
        ports:
          - "80:80"
          - "443:443"
        environment:
          - DOCKER_API_VERSION=${DOCKER_API_VERSION}
          - TRUST_PROXY_HEADER=true
        volumes:
          - ./letsencrypt:/letsencrypt
          - /var/run/docker.sock:/var/run/docker.sock:ro
        networks:
          default:
            aliases:
              - ${LOGTO_CORE_DOMAIN}
              - ${LOGTO_ADMIN_DOMAIN}
      app:
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.logto-core.rule=Host(`${LOGTO_CORE_DOMAIN}`)"
          - "traefik.http.routers.logto-core.entrypoints=websecure"
          - "traefik.http.routers.logto-core.tls.certresolver=myresolver"
          - "traefik.http.routers.logto-core.service=logto-core"
          - "traefik.http.services.logto-core.loadbalancer.server.port=3001"
          - "traefik.http.routers.logto-admin.rule=Host(`${LOGTO_ADMIN_DOMAIN}`)"
          - "traefik.http.routers.logto-admin.entrypoints=websecure"
          - "traefik.http.routers.logto-admin.tls.certresolver=myresolver"
          - "traefik.http.routers.logto-admin.service=logto-admin"
          - "traefik.http.services.logto-admin.loadbalancer.server.port=3002"
    ```

    Save and close the file.

    Traefik routes HTTPS traffic to Logto on subdomain-based host rules. Port 3001 serves the Core API and sign-in experience; port 3002 serves the Admin Console. Let's Encrypt certificates are provisioned automatically once DNS resolves to this server. This stack pins `svhd/logto` to the `TAG` value in `.env`, `traefik` to `v3.7.0`, and PostgreSQL to `17.5-alpine` for reproducible production deployments.

1. Start the Logto stack.

    ```console
    $ docker compose -f docker-compose.yml -f traefik/docker-compose.yml up -d
    ```

1. Verify the containers are running.

    ```console
    $ docker ps
    ```

    The output displays running containers for Traefik, Logto, and PostgreSQL.

1. Verify HTTPS on the Admin Console.

    ```console
    $ curl -sI https://admin.example.com
    ```

    The output returns `HTTP/2 302` with `location: /console/welcome` on first boot.

1. Verify the OIDC discovery endpoint.

    ```console
    $ curl -s https://auth.example.com/oidc/.well-known/openid-configuration | head -c 200
    ```

    The output returns JSON containing `authorization_endpoint` and `issuer` values scoped to your `auth.example.com` domain.

## Access the Admin Console

The Admin Console is the central management interface for configuring the Logto tenant.

1. Open a web browser and navigate to the Logto Admin Console at `https://admin.example.com`.
1. Follow the on-screen instructions to create the initial administrator account.
1. Log in to the dashboard using the new credentials.
1. Review the sidebar to confirm access to Applications, Sign-in & account, Multi-factor auth, Connectors, Enterprise SSO, API resources, Roles, Organizations, Webhooks, and Audit logs.

## Configure Sign-in Experience

The sign-in experience defines the look, feel, and authentication flow for your users. Logto allows you to customize the interface to match your brand identity.

### Set the Brand Identity

Branding settings control the logo and primary color applied to the hosted sign-in experience.

1. Navigate to **Sign-in & account** in the left sidebar. On first visit, click **Get started** to open the setup wizard, then click **Got it** to dismiss the introductory note.
1. Under **Branding area**, upload the company logo (for example, `https://example.com/logo.png`) and set the primary brand color (for example, `#6139F6`).
1. Click **Done**.

### Configure the Email Connector

To verify user identities via email and enable password resets, configure an email connector with your SMTP provider credentials.

1. Navigate to **Connectors** and select the **Email and SMS connectors** tab.
1. Click **Set up** under the **Email connector** and select **SMTP**.
1. Obtain the SMTP credentials from your email provider. You need the host, port, username, and password.
1. Return to the Logto Console and enter the following SMTP settings. Replace the placeholder values with your provider's credentials.
    * **host**: `SMTP-HOST`
    * **Port**: `SMTP-PORT`
    * **Auth**:
        * **type**: `login`
        * **user**: `SMTP-USERNAME`
        * **pass**: `SMTP-PASSWORD`
    * **From email**: `SENDER-EMAIL-ADDRESS`
    * **Reply to**: `REPLY-TO-EMAIL-ADDRESS`
1. Toggle **Secure** to **On** if your provider requires TLS.
1. Send a test email to verify the connection.
1. Click **Save and Done**.

### Define Sign-up Identifiers and Sign-in Methods

Select the primary methods users can use to create an account and sign in. Logto supports username, email, and phone-based authentication.

1. Navigate to **Sign-in & account** and select the **Sign-up and sign-in** tab.
1. Select the **Sign-up identifiers**:
    * **Username**: A unique public identifier.
    * **Email address**: Recommended for communication and password recovery.
    * **Phone number**: Enables SMS-based authentication for mobile-first applications.
1. Configure the **Sign-in methods** to allow users to sign in with their chosen identifiers.
1. Click **Save Changes**.

### Enable Passwordless Sign-in

Passwordless authentication reduces friction by allowing users to sign in with one-time codes instead of a password.

1. Remain on the **Sign-up and sign-in** tab.
1. Under **Sign-in methods**, enable **Email verification code** or **SMS verification code** as a sign-in option.
1. Ensure the corresponding email or SMS connector is configured under **Connectors** by selecting the **Email and SMS connectors** tab.
1. Click **Save Changes**.

### Preview the Sign-in UI

The Live preview renders the sign-in experience with the current branding and sign-in method configuration applied.

1. Click the **Live preview** button on the right side of the **Sign-up and sign-in** page.
1. Test the branded interface and enabled sign-in methods before applying changes to production traffic.

> [!NOTE]
> While this article focuses on email via SMTP, Logto also supports SMS-based registration and sign-in via third-party providers such as Twilio or Vonage. To use phone numbers, configure an SMS connector under **Connectors** by selecting the **Email and SMS connectors** tab. Users access the hosted sign-in UI through a registered application with a valid `client_id` and redirect URI, not by visiting `auth.example.com` directly. Direct navigation without an application context returns an unknown-session page.

## Set Up Social Login Connectors

Social login allows users to authenticate using their existing accounts from third-party identity providers, reducing friction during the registration process.

1. Navigate to **Connectors** in the left sidebar and select the **Social connectors** tab.
1. Click **Add Social Connector** and select **Google** from the list.
1. Follow the on-screen instructions to create a project in the [Google Cloud Console](https://console.cloud.google.com/):
    1. Create a new project.
    1. Navigate to **APIs & Services**, then select **OAuth consent screen**.
    1. Configure the consent screen and add the domain (for example, `example.com`) as an authorized domain.
    1. Go to **Credentials**, click **Create Credentials**, and select **OAuth client ID**.
    1. Select **Web application** as the application type.
    1. Add the Logto Callback URI (for example, `https://auth.example.com/callback/google`) to the **Authorized redirect URIs**.
1. Copy the **Client ID** and **Client Secret** provided by Google.
1. Paste the credentials into the corresponding fields in the Logto social connector configuration.
1. Configure the **Scope** field in Logto. By default, Logto requests `openid`, `profile`, and `email`. If the application requires additional Google API access (such as Calendar or Drive), append the respective scope URLs separated by spaces.
1. Click **Save and Done**.
1. Repeat the process for **GitHub** and **Apple** by selecting those providers from the **Add Social Connector** list and following each provider's OAuth configuration instructions.
1. Navigate to **Sign-in & account** and select **Sign-up and sign-in**.
1. Under **Social sign-in**, click **Add Social Connector** and select the connectors you configured.
1. Click **Save Changes** and use the **Live preview** to test the social sign-in flow.

## Configure Enterprise SSO

Enterprise Single Sign-On (SSO) enables corporate users to authenticate via their own Identity Provider (IdP), such as Okta or Microsoft Entra ID.

1. Navigate to **Enterprise SSO** in the left sidebar.
1. Click **Add enterprise connector** and select **Okta** (or **SAML** / **OIDC** for a generic enterprise connector).
1. Refer to the **Connection guide** button within the Logto Console for a direct link to the provider-specific setup instructions.
1. Follow the on-screen steps to create an OIDC application in your Okta dashboard:
    1. Register a new OIDC application.
    1. Set the **Login redirect URI** to the value provided in the Logto console.
    1. Obtain the **Client ID**, **Client Secret**, and **Issuer URL**.
1. Enter these details into the Logto connector configuration.
1. Click **Save** to save the connector credentials.
1. For SAML connectors, exchange IdP metadata with Logto by uploading the SAML metadata file or entering the metadata URL provided by your IdP.
1. Navigate to the **SSO Experience** tab in the connector settings.
1. Add the email domains associated with the organization (for example, `example.com`).
    > [!NOTE]
    > Users with matching email domains are automatically routed to the enterprise IdP login page. Other sign-in methods like social login or local passwords are disabled for these domains to enforce corporate security policies.
1. Enable **JIT provisioning** to create users automatically on first SSO sign-in.
1. Click **Save changes**.

## Enable Multi-Factor Authentication

Multi-factor Authentication (MFA) adds an extra layer of security by requiring secondary verification during the sign-in process.

1. Navigate to **Multi-factor auth** in the left sidebar.
1. Toggle the desired MFA methods to **On**:
    * **Authenticator app**: Standard time-based (TOTP) codes from apps like Google Authenticator.
    * **Passkeys**: High-security biometric (TouchID, FaceID) or hardware key (YubiKey) authentication using WebAuthn.
    * **Backup codes**: One-time use recovery codes for account fallback.
    * **SMS verification code** or **Email verification code**: Requires the corresponding connector configured under **Connectors** by selecting the **Email and SMS connectors** tab.
1. Configure the **MFA Policy** to determine when users are prompted (for example, optional MFA or required on every login).
1. Click **Save changes**.

## Configure RBAC and API Resources

Role-Based Access Control (RBAC) securely limits access to specific backend resources and endpoints based on a user's assigned role.

1. Navigate to **API Resources** and click **Create API resource**.
1. Enter an **API Name** and a unique **API Identifier** (for example, `https://api.example.com/orders`).
1. Define **Permissions (Scopes)** such as `read:orders` and `write:orders`.
1. Navigate to **Roles** and click **Create role**.
1. Assign the API permissions to the role and click **Save**.
1. On the **Assign user** screen, select users from the list and click **Assign user**, or click **Skip** to assign them later from the **User management** tab.
1. Navigate to **Custom JWT** in the left sidebar if global roles must appear in access tokens. Configure an access token script to inject role claims into issued JWTs.
1. Navigate back to **API Resources** and open the API resource you created.
1. Click **Check guide** in the top-right corner. The console displays a **Select a tutorial** dialog with framework options such as Express, Python, and Spring Boot.
1. Select the framework that matches your application. The console tutorial displays step-by-step integration code for initializing the Logto SDK, protecting API routes, and validating the access token against your API identifier.

## Set Up Organizations for Multi-Tenancy

Organizations offer multi-tenant isolation, allowing you to build B2B applications where users belong to different corporate entities. An organization template serves as a blueprint, defining a consistent set of roles and permissions available to every organization in your Logto tenant.

1. Navigate to **Organization template** in the left sidebar.
1. Create **Organization permissions**. These are fine-grained, non-API actions that define business logic or UI features within an organization.
    1. Click **Create organization permission**.
    1. Enter a **Permission name** (for example, `read:resource`) and Description.
    1. Repeat the process to create other permissions such as `edit:resource` and `delete:resource`.
1. Create **Organization roles**. These are collections of organization permissions or API resource permissions that you can assign to members.
    1. Click **Create organization role**.
    1. Enter a name (for example, `Admin` or `Member`) and a description.
    1. Map the previously created organization permissions and any relevant API resource permissions to the role.
1. Navigate to **Organizations** and click **Create organization** to provision a new tenant.
1. Select the organization and navigate to the **Members** tab.
1. Click **Add Members** and select users from the list.
1. Assign an organization role to each member from the role dropdown. Logto scopes JWT tokens to include the organization context when organization-scoped tokens are requested.
1. Click **Check guide** in the top-right corner to view integration tutorials for implementing multi-tenant features and org-scoped tokens in your application.

## Register Applications

Register your frontend and backend services as applications within Logto to authenticate users and obtain tokens.

> [!NOTE]
> Specific steps vary depending on the application type, such as **Single-Page App**, **Traditional Web App**, **Native App**, or **Machine-to-Machine**. Use the framework-specific tutorial provided in the console for detailed instructions.

1. Navigate to **Applications** in the left sidebar.
    * **Initial Setup**: If no applications exist, the console displays a grid of supported frameworks and languages (for example, React, Next.js, Node.js). Select your preferred framework to view the integration tutorial and click **Start building** to create the application.
    * **Subsequent Applications**: If you have already registered an application, click **Create application** in the top-right corner to add another.
1. Enter your application name and click **Create application**.
1. Follow the Jumpstart guide to integrate Logto with your application.
1. Configure the **Redirect URIs**, which dictate where Logto sends users after a successful sign-in.
1. Configure the **Post Sign-out Redirect URIs** to determine where users land after logging out.
1. Note the **App ID** and integration endpoint to initialize the Logto SDK in the application code.
1. Click **Save changes**.

Register at least three application types to cover common architectures:

* **Single-Page App (SPA)**: For React, Vue, or Angular frontends.
* **Traditional Web App**: For server-rendered applications with a backend session.
* **Machine-to-Machine (M2M)**: For backend services that call the Management API or protected APIs without user interaction.

Open the application sign-in URL or use the Logto SDK in a test client to confirm the redirect-based sign-in flow completes successfully.

## Configure Webhooks

Webhooks offer real-time notifications for identity events, allowing your backend systems to react asynchronously to changes within Logto without continuous polling.

1. Navigate to **Webhooks** in the left sidebar and click **Create webhook**.
1. Enter the backend **Endpoint URL** and assign a descriptive name.
1. Select the specific **Webhook events** to monitor (for example, `User.Created`, `PostSignIn`, or `User.Data.Updated`).
1. Add optional **Custom headers** if the receiving endpoint requires authentication tokens or other metadata in the request.
1. Click **Create webhook**.
1. Secure the webhook. Logto provides a **Signing Key** in the webhook settings. Use this key to cryptographically verify that incoming payloads originated from the Logto instance and have not been tampered with.
1. Send a test payload to confirm the endpoint receives and processes webhook events.

## Verify the Deployment

After configuration, run the following checks to confirm the deployment is healthy end to end.

1. **Infrastructure**: Confirm all containers are running with `docker ps`. Traefik, Logto, and PostgreSQL should report an `Up` status.
1. **TLS**: Open `https://admin.example.com` and `https://auth.example.com` in a browser. Both should load with valid Let's Encrypt certificates.
1. **OIDC discovery**: Run `curl -s https://auth.example.com/oidc/.well-known/openid-configuration` and confirm the `issuer` matches `https://auth.example.com/oidc`.
1. **Admin Console**: Create the initial admin account and confirm the dashboard loads with all sidebar sections (Applications, Sign-in & account, MFA, Connectors, Enterprise SSO, API resources, Roles, Organizations, Webhooks, Audit logs).
1. **User registration and sign-in**: Register a test user through the application you created in the **Register Applications** section. Confirm password-based sign-in works.
1. **Social login**: If configured, test Google, GitHub, or Apple sign-in through the Live preview or application redirect flow.
1. **MFA**: Enable TOTP for a test user and confirm the second factor is enforced on the next sign-in.
1. **RBAC claims**: Request an access token for an API resource and verify the token contains the expected scopes after role assignment.
1. **Organization-scoped login**: Add a user to an organization, sign in, and confirm organization context appears in the token or session as documented in the organization integration tutorial.
1. **Audit logs**: Navigate to **Audit logs** in the Admin Console and confirm sign-in and configuration events are recorded.

## Migrate from AWS Cognito to Logto

Migrating from [AWS Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/what-is-amazon-cognito.html) to Logto involves mapping User Pool resources to Logto tenants, replacing Amplify or Cognito SDK calls with Logto SDKs, and converting Lambda triggers to webhooks or Custom JWT scripts. Because Cognito does not export password hashes or MFA secrets, most migrations follow a bulk user import with mandatory re-authentication strategy. The guidance below assumes you completed **Deploy Logto with Docker Compose**, **Access the Admin Console**, and **Register Applications** earlier in this article.

### User Migration

An AWS Cognito User Pool bundles user directories, authentication flows, app clients, and groups into a single managed resource. Logto splits these responsibilities across users, the sign-in experience, applications, roles, and organizations within a self-hosted tenant.

* **Export**: Retrieve user profiles from Cognito using the AWS CLI (`list-users`) or the [ListUsers API](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html).
* **Import**: Iterate over the exported data and create users through the [Logto Management API](https://openapi.logto.io/) on the Core endpoint (`POST /api/users` at `https://auth.example.com/api`). Authenticate with an access token from a Logto Machine-to-Machine application.
* **Passwords**: Cognito does not expose password hashes. Import users with temporary credentials and trigger a password reset or forgot-password flow on first login.
* **MFA enrollments**: TOTP seeds and WebAuthn credentials cannot be exported. Users must re-enroll authenticator apps, passkeys, or SMS factors after migration.
* **Identity mapping**: Store the original Cognito `sub` UUID in Logto `customData` (for example, `legacy_cognito_sub`) during import to preserve linkages in downstream application databases.

### Application Migration

Application changes depend on how clients integrate with Cognito.

**If applications use the AWS Amplify Auth library** (the most common pattern), replace [Amplify Auth APIs](https://docs.amplify.aws/react/build-a-backend/auth/) with the [Logto SDK](https://docs.logto.io/quick-starts/) for your framework:

* **`signInWithPassword` / embedded forms**: Redirect-based Universal Login through the Logto hosted sign-in experience
* **User Pool App Client ID**: Logto Application ID (`client_id` in OIDC)
* **Callback URLs**: Redirect URIs and Post Sign-out Redirect URIs configured in the Logto Console
* **Token refresh**: Logto SDK session management or standard OIDC refresh token flows

**If applications call the Cognito API directly** or use the [Amazon Cognito Identity SDK](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html), replace those calls with Logto SDK methods or direct OIDC endpoints:

* **`InitiateAuth` / `AdminInitiateAuth`**: OIDC authorization code flow with PKCE (browser apps) or client credentials flow (M2M)
* **`GetUser`**: OIDC UserInfo endpoint or Management API user lookup
* **Access tokens**: Validate against the Logto JWKS endpoint (`https://auth.example.com/oidc/jwks`) with issuer `https://auth.example.com/oidc`

In both cases, update backend middleware to validate Logto-issued JWTs instead of Cognito JWTs. Refer to the [Logto protect-your-api documentation](https://docs.logto.io/authorization/protect-your-api) for framework-specific examples.

### Role and Group Migration

Cognito Groups provide coarse role assignment within a User Pool. Logto offers two mapping paths depending on whether groups represent global permissions or tenant-scoped membership.

* **Cognito Groups → Logto Roles**: Groups that gate API access or admin capabilities map to global Roles. Create each role (`POST /api/roles`), define API resource permissions, and assign users (`POST /api/users/{userId}/roles`). Global roles are not included in access tokens by default; configure a **Custom JWT** access token script in the Admin Console to inject role claims.
* **Cognito Groups → Logto Organizations**: Groups that represent B2B tenants or corporate entities map to Organizations. Create the organization (`POST /api/organizations`), define organization roles in the **Organization template**, and add members (`POST /api/organizations/{id}/users`).
* **Authorization enforcement**: Update backend route guards and policy engines to parse the claims your Custom JWT script emits rather than Cognito's `cognito:groups` claim.

### Lambda Trigger Migration

Cognito [Lambda triggers](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html) run inline during the authentication lifecycle. Logto does not support synchronous blocking hooks; each trigger type maps to a different replacement with distinct operational characteristics.

* **Post-confirmation / Post-authentication (async)**: Map to Logto Webhooks for events such as `User.Created`, `PostSignIn`, or `User.Data.Updated`. Webhooks deliver HTTP payloads asynchronously after the auth flow completes. Refer to the [Logto webhook documentation](https://docs.logto.io/docs/recipes/webhook/).
* **Pre-token generation (sync, claims modification)**: Map to **Custom JWT** access token scripts in the Admin Console. Scripts run in a sandbox during token issuance to inject roles, organization memberships, or custom attributes into the JWT.
* **Pre-authentication / Pre-sign-up (sync, blocking)**: Map to application middleware, API gateway rules, or a custom authentication proxy. Logto webhooks cannot block or reject an in-progress sign-in synchronously.
* **Custom message**: Map to email or SMS connectors configured under **Connectors**, or handle notification logic in a webhook consumer that calls your messaging provider.

Unlike Lambda triggers, which scale per invocation and run only during auth events, Custom JWT scripts execute on every token issuance and webhook consumers run as always-on services. Account for this operational difference when planning capacity.

### Data Storage Considerations

For environments with existing identity data and active sessions:

* **Session invalidation**: Cognito sessions and refresh tokens become invalid at cutover. Force re-authentication across all client applications and clear local session caches.
* **Downstream identity references**: Applications that store Cognito `sub` values in their own databases rely on the `legacy_cognito_sub` mapping in Logto `customData` until those references are updated.
* **Management API integration**: Replace calls to Cognito IDP endpoints (`AdminGetUser`, `ListUsers`, `AdminUpdateUserAttributes`) with the Logto Management API at `https://auth.example.com/api`. Authenticate M2M clients with a Logto Machine-to-Machine application.
* **Federation metadata**: If Cognito federates external IdPs through SAML or OIDC, recreate those federation relationships as Logto Enterprise SSO connectors or social connectors rather than attempting to migrate Cognito's internal federation configuration directly.

### Things to Take Care During Migration

The following considerations affect the scope and sequencing of a Cognito-to-Logto migration.

* **Amplify SDK to Logto SDK**: Embedded sign-in forms and direct API calls must move to redirect-based OIDC flows. This is the largest application-code change in most migrations.
* **Lambda triggers**: Cognito supports synchronous inline triggers. Logto webhooks are asynchronous only; blocking validation requires application middleware or an API gateway.
* **Identity Pools**: Cognito Identity Pools grant AWS resource access via IAM roles. Logto has no equivalent. Provide AWS access through M2M API gateways, IAM role assumption via STS, or application-level credentials.
* **Advanced Security**: Cognito Advanced Security (compromised credential detection, adaptive authentication) has no direct Logto OSS equivalent. Implement rate limiting, WAF rules, or bot protection at the reverse proxy layer.
* **MFA re-enrollment**: TOTP secrets and WebAuthn credentials cannot be extracted from Cognito. Users must re-enroll authenticator apps, passkeys, or SMS factors after cutover.
* **Token format differences**: Cognito access tokens use custom claims such as `cognito:groups` and `cognito:username`. Logto issues standard OIDC claims (`sub`, `email`, `scope`). Update API parsers and authorization middleware accordingly.
* **Hosted UI customization**: Cognito Hosted UI CSS customization maps to the Logto sign-in experience branding settings under **Sign-in & account**. Complex custom login pages require building a custom UI with the Logto SDK instead of CSS overrides.
* **Cost model change**: Cognito charges per monthly active user and per MFA authentication. Logto OSS costs are infrastructure-based, covering compute, storage, and operational overhead. Calculate total cost of ownership before cutover.
* **Cutover sequencing**: Run a phased migration with dual-write or read-replica validation where possible. Import users first, validate token flows in a staging tenant, then redirect production traffic to Logto and disable the Cognito User Pool.

## Conclusion

You have deployed Logto with a Traefik reverse proxy, configured the sign-in experience, social and enterprise SSO connectors, MFA, RBAC, organizations, applications, and webhooks, and verified the deployment end to end. The migration section outlines how to move an existing AWS Cognito user base to Logto when a cutover is required. For additional configuration options and SDK integrations, refer to the [official Logto documentation](https://docs.logto.io/).