Kind: Interface
Source: src/adapter/aws-lambda/types.ts
Part of: Adapter
CognitoIdentity describes the Amazon Cognito identity attached to an AWS Lambda request. It carries the identity ID and the Cognito identity pool ID so adapter code can read the caller's Cognito context.
Properties
| Property | Type |
|---|---|
cognitoIdentityId | string |
cognitoIdentityPoolId | string |
Diagram
mermaidgraph LR Request[AWS Lambda request] --> Identity[CognitoIdentity] Identity --> IdentityId[cognitoIdentityId] Identity --> PoolId[cognitoIdentityPoolId]
Usage
tsimport type { CognitoIdentity } from './types'
function getIdentityContext(identity: CognitoIdentity) {
return {
identityId: identity.cognitoIdentityId,
poolId: identity.cognitoIdentityPoolId,
}
}
const identity: CognitoIdentity = {
cognitoIdentityId: 'identity-value',
cognitoIdentityPoolId: 'pool-value',
}
const context = getIdentityContext(identity)
AI Coding Instructions
- Keep both interface properties as strings.
- Read
cognitoIdentityIdwhen request handling needs the Cognito caller identity. - Read
cognitoIdentityPoolIdwhen code needs to distinguish the originating identity pool. - Handle missing Cognito context before constructing or consuming this interface when Lambda events may be unauthenticated.
How it works
CognitoIdentity is an exported TypeScript interface with two required string fields:
cognitoIdentityId: a string.src/adapter/aws-lambda/types.ts:3-5cognitoIdentityPoolId: a string.src/adapter/aws-lambda/types.ts:3-6
It is used as the optional identity member of LambdaContext; a handler context may therefore omit it, or contain an object matching this interface. src/adapter/aws-lambda/types.ts:35-45
The interface declares no methods, runtime validation, thrown errors, or side effects. src/adapter/aws-lambda/types.ts:3-6
Was this page helpful?