Skip to content

Cognito

CloudMock emulates Amazon Cognito User Pools, supporting user pool and client management, admin user operations, self-service sign-up, and authentication with synthetic JWT tokens.

OperationStatusNotes
CreateUserPoolSupportedCreates a user pool
DeleteUserPoolSupportedDeletes a user pool and all users
DescribeUserPoolSupportedReturns user pool details
ListUserPoolsSupportedReturns all user pools
CreateUserPoolClientSupportedCreates an app client for a user pool
DescribeUserPoolClientSupportedReturns app client details
ListUserPoolClientsSupportedReturns all clients for a user pool
AdminCreateUserSupportedCreates a user in a pool (admin API)
AdminGetUserSupportedReturns user details (admin API)
AdminDeleteUserSupportedDeletes a user (admin API)
AdminSetUserPasswordSupportedSets a user’s password (admin API)
SignUpSupportedUser self-registration
InitiateAuthSupportedStarts the authentication flow
AdminConfirmSignUpSupportedConfirms a user’s registration (admin API)
Terminal window
# Create a user pool
curl -X POST http://localhost:4566 \
-H "X-Amz-Target: AWSCognitoIdentityProviderService.CreateUserPool" \
-H "Content-Type: application/x-amz-json-1.1" \
-d '{"PoolName": "MyApp"}'
# Create an app client
curl -X POST http://localhost:4566 \
-H "X-Amz-Target: AWSCognitoIdentityProviderService.CreateUserPoolClient" \
-H "Content-Type: application/x-amz-json-1.1" \
-d '{"UserPoolId": "us-east-1_XXXXXXXX", "ClientName": "web-client"}'
import { CognitoIdentityProviderClient, CreateUserPoolCommand, AdminCreateUserCommand, InitiateAuthCommand } from '@aws-sdk/client-cognito-identity-provider';
const cognito = new CognitoIdentityProviderClient({
endpoint: 'http://localhost:4566',
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
const pool = await cognito.send(new CreateUserPoolCommand({ PoolName: 'MyApp' }));
const poolId = pool.UserPool!.Id!;
await cognito.send(new AdminCreateUserCommand({
UserPoolId: poolId, Username: 'alice', TemporaryPassword: 'Temp123!',
}));
import boto3
idp = boto3.client('cognito-idp', endpoint_url='http://localhost:4566',
aws_access_key_id='test', aws_secret_access_key='test',
region_name='us-east-1')
pool = idp.create_user_pool(PoolName='MyApp')
pool_id = pool['UserPool']['Id']
client = idp.create_user_pool_client(
UserPoolId=pool_id, ClientName='backend',
ExplicitAuthFlows=['ALLOW_USER_PASSWORD_AUTH', 'ALLOW_REFRESH_TOKEN_AUTH'],
)
client_id = client['UserPoolClient']['ClientId']
idp.admin_create_user(UserPoolId=pool_id, Username='bob', TemporaryPassword='Tmp1!')
idp.admin_set_user_password(UserPoolId=pool_id, Username='bob', Password='Perm1!', Permanent=True)
response = idp.initiate_auth(
AuthFlow='USER_PASSWORD_AUTH', ClientId=client_id,
AuthParameters={'USERNAME': 'bob', 'PASSWORD': 'Perm1!'},
)
print(response['AuthenticationResult']['AccessToken'])
cloudmock.yml
services:
cognito:
enabled: true

No additional service-specific configuration is required.

  • Tokens returned by InitiateAuth are synthetic JWTs. They are accepted by the CloudMock IAM middleware but cannot be verified against a real Cognito JWKS endpoint.
  • MFA, custom authentication flows, and identity pools (Cognito Federated Identities) are not implemented.
  • Password policies are accepted in CreateUserPool but not enforced.
  • Email/SMS verification is not performed; users can be confirmed via AdminConfirmSignUp.
  • Hosted UI and OAuth flows are not implemented.
CodeHTTP StatusDescription
ResourceNotFoundException400The specified user pool does not exist
UsernameExistsException400A user with this username already exists
NotAuthorizedException400Invalid username or password
UserNotFoundException400The specified user does not exist
InvalidParameterException400An input parameter is not valid