AWS in 1 Min · Episode 34

Amazon Cognito explained: sign-in for your app

Sign-in for your app. Watch the one-minute video, then read the details.

David Gomez1:13 video · 3 min read

"Building your own login is easy." The first screen is. Then come password resets, verification codes, multi-factor authentication, social logins, locked accounts and safe password storage, and a mistake in any of them can leak your users. Amazon Cognito is the AWS service that handles sign-up and sign-in for your app's users, so you don't build that from scratch.

Cognito is not IAM

IAM and IAM Identity Center are for your team: the people who build and operate things in AWS. Cognito is for your customers: the people who use the web or mobile app you built. Don't create IAM users for customers.

Cognito has two parts that answer two different questions. You can use either one alone, or both together.

User pools: who is this user?

A user pool is a user directory and an authentication service. It can:

  • let people sign up and sign in with a username, email or phone number
  • store user profiles and check passwords for you
  • require multi-factor authentication, with codes by text message or from an authenticator app
  • provide managed login, a hosted sign-in page you can brand, so you don't have to design the screens
  • let people sign in through Google, Apple, Facebook or Amazon, or through a company identity provider that speaks SAML 2.0 or OpenID Connect

After a successful sign-in, the user pool gives your app tokens. They are JSON Web Tokens (JWTs): small, digitally signed documents that state who the user is and when the proof expires. Your back end doesn't need to see the password. It only verifies the token's signature and expiry on each request.

Identity pools: what AWS resources may they reach?

An identity pool exchanges a trusted token, from a user pool or from another provider, for temporary, limited AWS credentials. That lets the app itself call AWS services on the user's behalf, for example uploading a photo straight to an S3 bucket. An identity pool can also issue restricted credentials to guests who haven't signed in.

Many apps never need one. If your app only talks to your own API, a user pool is enough. Add an identity pool when the app must call AWS services directly.

A common mistake

Trusting the token without checking it properly. Your API must verify the signature, the expiry and that the token was issued by your user pool for your app. Better still, let AWS do it: Amazon API Gateway can validate user pool tokens before a request ever reaches your code.

Also give identity pool roles the least access possible. Those credentials end up on your users' devices.

Where AI fits

An AI chatbot without a login is an open tap: anyone who finds the address can spend your model budget, and you can't tell users apart. Cognito puts sign-in in front of it.

A typical setup:

  1. The user signs in through a Cognito user pool and the app receives tokens.
  2. Each chat request goes to API Gateway with the token attached.
  3. API Gateway checks the token. No valid token, no request.
  4. Only then does your code call the model, for example through Amazon Bedrock.

Because the token identifies the user, you can also keep conversations separate per user and set per-user limits. For AI agents, Amazon Bedrock AgentCore can use the same approach: its documentation shows a Cognito user pool as the identity provider for JWT-based inbound authorization. Check the current guide before building on it, since this area moves quickly.

Quick recap

  • Cognito handles sign-up and sign-in for your app's users; IAM is for your team.
  • User pools prove who someone is and issue signed tokens.
  • Identity pools swap that proof for temporary AWS credentials.
  • Put Cognito and API Gateway in front of your chatbot so only signed-in users spend tokens.
AWS in 1 Min #34 · 1:13

Need an AWS expert on your team?

I'm David, an AWS expert and fractional cloud consultant. I work alongside your team to run your cloud and infrastructure: architecture, security, cost and day-to-day operations. You get senior AWS experience when you need it, without the cost of a full-time hire.

  • Architecture reviews and a clear plan for what to fix first
  • Security hardening: IAM, networking, audits
  • Lower AWS bills without slowing your team down
  • Hands-on help with AI workloads on AWS