Amazon Cognito
Cloud service · AWS · Updated

Amazon Cognito

In short

Amazon Cognito is a cloud service provided by Amazon Web Services (AWS) that provides authentication, authorization, and user management for web and mobile applications.

Cloud Services Hub →

Free Amazon Cognito tools

6 key features of Amazon Cognito

Amazon Cognito offers secure user authentication, is easily scalable, ensures compliance, provides customizable user experiences, and supports data synchronization across devices.

01
User Authentication

Amazon Cognito provides user authentication with social identity providers like Google, Facebook, and Amazon, as well as with user pools for direct sign-in functionality.

02
Security and Compliance

It ensures data security and compliance by offering features such as encryption at rest and in transit, MFA (Multi-Factor Authentication), and compliance with various certifications and regulations.

03
Customizable User Experience

Enables customization of the user experience with UI customization, messages customization, and user pool domains to maintain consistent branding across your applications.

04
Serverless and Scalable

Designed to be serverless and scalable, it automatically scales to handle millions of users without requiring any infrastructure management.

05
Data Synchronization

Offers data synchronization across devices and platforms, allowing a seamless user experience and access management for your applications.

06
Anonymous Guest Access

Identity pools support anonymous guest users, allowing applications to grant access to AWS services without requiring users to sign in.

Where Amazon Cognito is used

Amazon Cognito is used for secure user authentication and authorization, federated identity management, direct AWS resource access, multi-factor authentication, and creating custom authentication flows for web and mobile applications.

  1. 01
    User Authentication and Authorization

    Amazon Cognito facilitates secure user sign-up, sign-in, and access control to web and mobile applications, eliminating the need for backend code to authenticate users and manage user-specific tokens.

  2. 02
    Federated Identities

    Cognito supports identity federation that allows users to sign in through social identity providers such as Google, Facebook, and Amazon, as well as enterprise identity providers via SAML 2.0, thus simplifying the login process and enhancing user experience.

  3. 03
    Secure Access to AWS Services

    With Cognito, developers can assign user-specific permissions to access AWS resources directly from the front-end application, ensuring a fine-grained access control mechanism.

  4. 04
    Multi-factor Authentication

    It provides additional security by enabling multi-factor authentication (MFA), which requires users to verify their identity through multiple methods before being granted access.

  5. 05
    Custom Authentication Flows

    Amazon Cognito allows for the creation of custom authentication workflows using AWS Lambda triggers, enabling unique authentication processes tailored to specific business requirements.

How Amazon Cognito is priced

Amazon Cognito's pricing is primarily based on the number of Monthly Active Users (MAUs), with the first 50,000 being free, and includes additional costs for federation and using custom authentication flows with AWS Lambda.

Monthly Active Users (MAUs)

Amazon Cognito user pools are billed by monthly active users. The standard free tier for direct or social sign-in is 10,000 MAUs per month per account or AWS organization for Lite and Essentials; Plus has no such free tier. Free-tier pricing is unavailable in AWS GovCloud (US).

Federation

Users signing in through SAML or OIDC federation have separate MAU pricing: the first 50 MAUs are free, and additional MAUs cost $0.015 each. Social identity provider sign-ins are included with direct user-pool sign-ins rather than this enterprise federation rate.

Custom Authentication Flows

Using AWS Lambda triggers for custom authentication flows may incur additional costs. These costs are associated with the use of AWS Lambda, which Cognito uses to execute custom scripts for authentication, verification, and other custom processes.

Advanced Security Features

Enabling Advanced Security Features incurs additional MAU charges on top of base user-pool pricing, including when operating in audit mode.

SMS Messages

SMS messages for MFA, registration, password recovery, and phone-number verification are charged separately through Amazon SNS.

Email Messages

Email messages for registration, password recovery, and email-address verification are charged separately through Amazon SES.

Cognito Sync

Cognito Sync charges for stored data and synchronization operations. Eligible customers receive 10 GB of cloud sync storage and 1,000,000 sync operations per month for the first 12 months.

Higher API Quotas

Additional API capacity is charged per incremental request per second above default quotas, with each API category billed separately.

Machine-to-Machine Authorization

M2M authorization is billed monthly per successful token response, with no additional charge for registered app clients.

Multi-Region Replication

Multi-Region replication adds charges to base tier pricing per MAU or successful token request. Each unique user is counted once globally across the primary and secondary Regions.

Services Amazon Cognito works with

Amazon API GatewayAmazon API Gateway

Cognito can be used to secure RESTful APIs created with API Gateway. It provides user authentication and authorization, allowing only authenticated and authorized users to access API endpoints.

AWS LambdaAWS Lambda

Lambda functions can be triggered by events in Cognito, such as user sign-up, sign-in, and attribute updates. This allows for custom authentication workflows, data processing, and other event-driven actions.

Amazon S3Amazon S3

Cognito integrates with S3 to provide secure access to S3 buckets. You can use Cognito to manage permissions and provide users with temporary credentials to access S3 resources.

Amazon DynamoDBAmazon DynamoDB

Cognito can be used with DynamoDB to store user profile data and application state. This allows for seamless integration of user data management with your application backend.

AWS Identity and Access Management (IAM)AWS Identity and Access Management (IAM)

Cognito integrates with IAM to provide fine-grained access control to AWS resources. It allows you to define roles and policies that dictate what resources users can access based on their authentication and authorization status.

Amazon CloudWatchAmazon CloudWatch

Cognito integrates with CloudWatch for monitoring and logging. You can track metrics related to user authentication, authorization, and usage, and set up alarms for specific events.

Amazon RDSAmazon RDS

Cognito can integrate with RDS for storing and managing relational user data. This can be used for applications requiring complex queries and transactions on user data.

Amazon Augmented AI (Amazon A2I)Amazon Augmented AI (Amazon A2I)

Amazon Cognito authenticates members of private workforces used for Amazon A2I human review. Reviewers sign in to the worker portal with accounts in the workforce's Cognito user pool.

Amazon Bedrock AgentCore

Amazon Cognito user pools can issue access tokens for AgentCore endpoints configured with JWT authentication. AgentCore validates the tokens against the configured Cognito issuer and client settings before allowing access.

Amazon CloudFrontAmazon CloudFront

Amazon Cognito provisions a CloudFront distribution when you configure a custom domain for user-pool managed login. The distribution serves the sign-in endpoints over HTTPS using the certificate associated with that custom domain.

Alternatives to Amazon Cognito in other clouds

Azure

Microsoft Entra External ID

Amazon Cognito and Microsoft Entra External ID provide customer registration, sign-in, and access control for web and mobile apps. Cognito stores customer identities in user pools and extends authentication with AWS Lambda triggers, while Entra External ID uses dedicated external tenants and calls REST endpoints for supported authentication events.

Compare fact by fact
Amazon CognitoMicrosoft Entra External ID
Customer identity directoryCognito user poolDedicated external tenant
Free monthly active users10,000 direct/social (Lite/Essentials)50,000 (core offering)
Custom authentication hooksAWS Lambda triggersREST endpoints
Microsoft Entra ID B2C

Amazon Cognito and Microsoft Entra ID B2C manage customer accounts and support direct and federated sign-in for web and mobile apps. Cognito customizes authentication with AWS Lambda triggers, while Entra ID B2C uses XML policies, and the services offer different free allowances for monthly active users.

Compare fact by fact
Amazon CognitoMicrosoft Entra ID B2C
Custom authenticationAWS Lambda triggersXML custom policies with REST calls
Free monthly active users10,000 direct/social (Lite, Essentials)50,000 under the MAU offer
Service tiersLite, Essentials (default), PlusB2C P1

What is Amazon Cognito

3 min read

Amazon Cognito is a sophisticated service offered by Amazon Web Services (AWS) that provides authentication, authorization, and user management for web and mobile applications. The service is designed to be highly scalable, secure, and flexible, thus enabling developers to add user sign-up, sign-in, and access control to their applications quickly and easily, without worrying about the back-end infrastructure and security mechanisms typically associated with these features. 

At its core, Amazon Cognito allows applications to authenticate users through various methods including social identity providers such as Google, Facebook, and Amazon, as well as through enterprise identity providers via SAML 2.0. Moreover, it provides its own secure and scalable user directory that can scale to hundreds of millions of users. This is particularly appealing for developers looking to manage user identities and federations without having to maintain a separate backend system for this purpose. 

For machine-to-machine authorization, app clients use the OAuth 2.0 client credentials flow to exchange credentials for access tokens that they can use to communicate with services. Access-token validity can be configured per service.

API request-rate quotas apply per AWS account and Region and are shared across user pools in that Region. A quota increase in one Region does not increase the request rate available in another Region.

When configuring a user pool, you can choose Lite, Essentials, or Plus. Lite provides basic registration, authentication, and user management. Essentials adds Managed Login, passwordless sign-in with passkeys or email and SMS one-time passwords, access-token customization, and password-reuse prevention. Plus adds threat protection, including risk-based adaptive authentication, compromised-credential detection, and authentication-event log export. Essentials is the default for new user pools, and pools can switch tiers.

One of the standout features of Amazon Cognito is its ability to offer seamless authentication and authorization across multiple devices and platforms. A signed-in session is not automatically transferred from one device to another; a new device generally requires authentication unless the application implements a secure session-transfer mechanism. This is facilitated through the use of tokens which are securely managed by Cognito. Data synchronization is another noteworthy feature of Amazon Cognito. It allows user data such as app preferences or game states to be synchronized across various devices, enabling a consistent user experience regardless of the platform being used. This data is stored in the AWS Cloud, which ensures its availability and scalability. 

Amazon Cognito also places a strong emphasis on security. It encrypts data at rest and in transit, and operates in Amazon highly secure data centers. It allows for multi-factor authentication (MFA) and the use of strong password policies to enhance security further. The service is compliant with various industry standards, including ISO/IEC 27001, ensuring that applications using Cognito adhere to strict data protection regulations. 

Multi-Region replication can synchronize user data, credentials, and user-pool configurations to additional AWS Regions for regional failover while preserving active sessions. It requires a multi-Region customer managed AWS KMS key and, where applicable, a multi-Region OIDC issuer configuration; regional failover is configured to meet your operational requirements.

In terms of integration, Amazon Cognito provides APIs and SDKs for a wide range of platforms including Android, iOS, and the web, making it a versatile option for developers across various environments. This ease of integration, coupled with its comprehensive feature set, makes Amazon Cognito a powerful solution for managing user identities and ensuring secure and seamless access to web and mobile applications. 

In essence, Amazon Cognito relieves developers of the complexity associated with creating, maintaining, and securing a system for user management and authentication, allowing them to focus on developing the core features of their applications. Its scalability ensures that the solution remains viable as the application user base grows, which is a critical consideration for any online platform looking to expand its reach.

Concepts related to Amazon Cognito

Amazon Cognito exam questions

Real practice exam questions on Amazon Cognito, with the correct answer and its explanation. Answer them with every option in the exam simulator.

CLF-C02

A photo-sharing mobile application already authenticates customers through an OpenID Connect identity provider. After signing in, customers need temporary, limited AWS credentials to upload photos directly to Amazon S3. The company does not want to create IAM users for customers or build its own credential broker. Which solution best meets these requirements?

Show answerCORRECT ANSWER

Configure an Amazon Cognito identity pool to trust the existing identity provider and assign an IAM role with the required S3 permissions.

Amazon Cognito identity pools can exchange tokens from a supported identity provider for temporary AWS credentials. An associated IAM role defines the S3 permissions available to authenticated customers.

DVA-C03

A company runs a training portal where independent instructors sign in directly with accounts in an existing user directory. The company wants instructors from a university to sign in through the university's OpenID Connect (OIDC) identity provider. The provider returns a campus_code claim only from its userinfo endpoint and only when the profile scope is requested. After sign-in, the portal must read the campus code from an ID token issued by the same issuer it already trusts. The portal must not call the university's userinfo endpoint itself. Which configuration meets these requirements?

Show answerCORRECT ANSWER

Add the university as an OIDC provider in the existing Amazon Cognito user pool. Enable it for the portal's app client alongside direct sign-in. Request `openid profile` from the provider, map `campus_code` to a mutable custom attribute, and give the app client read and write access to that attribute. Use the user pool's ID token.

The user pool brokers OIDC sign-in and can retrieve the claim from the provider's `userinfo` endpoint. Cognito maps the claim to the custom profile attribute and includes the readable attribute in its own ID token. The same app client can continue to support direct sign-in.

SAP-C03

A company operates production and test versions of a mobile application. Both versions authenticate users through the same Amazon Cognito user pool but exchange tokens for AWS credentials through separate Cognito identity pools. The production identity pool also supports guest access through a separate, restricted IAM role. Both identity pools support the basic (classic) authentication flow.

The company wants to reuse an existing IAM role named ProductionUploader for signed-in production users. Its permissions policy already grants the required access. The role currently trusts only an EC2 instance profile workflow, which is being retired.

A security review requires that ProductionUploader cannot be assumed by guests or by identities from the test identity pool, even if a client explicitly requests this role. Valid signed-in production users must continue to obtain credentials without a custom credential broker.

Which replacement trust policy meets these requirements?

Show answerCORRECT ANSWER

Allow sts:AssumeRoleWithWebIdentity with Principal.Federated set to cognito-identity.amazonaws.com. Require StringEquals on cognito-identity.amazonaws.com:aud with the production identity pool ID and ForAnyValue:StringLike on cognito-identity.amazonaws.com:amr with authenticated. Include no other Allow statements.

The federated principal establishes trust in Amazon Cognito identities. The aud condition restricts assumption to identities from the production identity pool, and the amr condition requires an authenticated identity. Together, these conditions exclude both guests and identities from the test pool, including attempts to explicitly request the role through the basic flow.

Practice Amazon Cognito in a full exam

Questions on Amazon Cognito in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

Learn Amazon Cognito in lessons

15 short lessons on Amazon Cognito in 5 certification courses.

and 9 more lessons

Open the lessons

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.