Registry / database / dm-driver-cognito

dm-driver-cognito

JSON →
library1.6.0jsnpmunverified

A Data Migration driver for querying and modifying Amazon Cognito user pools. Version 1.6.0 is the current stable release, maintained as part of the data-migration monorepo with Lerna. It integrates with the data-migration framework and supports cloudformation parameter resolution via dm-processor-cf. Compared to direct AWS SDK usage, it provides a migration-oriented abstraction with addUser, getUser, and deleteUser methods within a staging and migration directory structure.

npm install dm-driver-cognito
INSTALL
IMPORT
SIG · DM-DRIVER-COGNITO
D
dm-driver-cognito
databasejavascriptv1.6.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ const cognitoDriver = require('dm-driver-cognito')
✗ import cognitoDriver from 'dm-driver-cognito'
Package does not ship ESM; use CommonJS require().
UserPoolDriver
✓ type UserPoolDriver = InstanceType<typeof import('dm-driver-cognito')>
✗ import { UserPoolDriver } from 'dm-driver-cognito'
UserPoolDriver is not exported; use type inference from the driver instance returned by data-migration context.
ScriptContext
✓ import { ScriptContext } from 'data-migration'
✗ import { ScriptContext } from 'dm-driver-cognito'
ScriptContext is part of the core data-migration package, not this driver.

Configures a Cognito driver using a CloudFormation stack output for the user pool ID, then creates a user in an up migration and deletes it in down.

// dm.config.js module.exports = { defaultStage: "dev", migrationDirectory: "./migrations", stages: { dev: { defaultParams: { region: "us-east-1", profile: "my-profile", // optional }, drivers: { users: { driver: require("dm-driver-cognito"), params: { userPoolDriver: { processor: require("dm-processor-cf"), params: { stack: "MyUserPoolStack", output: "UserPoolId", }, }, }, }, }, }, }, }; // migrations/001-create-user.ts import { ScriptContext, Logger } from 'data-migration'; export async function up(context: ScriptContext, log: Logger) { const userPool = await context.getDriver("users"); await userPool.addUser("jdoe", "TempPass123!", { UserAttributes: [ { Name: "email", Value: "jdoe@example.com" }, ], }); log.info("User jdoe created"); } export async function down(context: ScriptContext, log: Logger) { const userPool = await context.getDriver("users"); await userPool.deleteUser("jdoe"); log.info("User jdoe deleted"); }
Debug
Known issues
gotchaThe driver requires a configured AWS credential source (environment variables, profile, or IAM role). Ensure credentials are available before running migrations.
fix
Set AWS credentials via environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) or configure an AWS profile.
affects: >=1.0
gotchaThe driver does not support ESM imports; CommonJS require() is mandatory.
fix
Use const cognitoDriver = require('dm-driver-cognito') in your config file.
affects: >=1.0
deprecatedThe driver uses the AWS SDK v3 package @aws-sdk/client-cognito-identity-provider. Ensure you have the correct version installed.
fix
Add @aws-sdk/client-cognito-identity-provider as a dependency if not already present.
affects: >=1.0
gotchaThe userPool parameter can be a string ID or a processor object. Misconfiguring this will cause runtime errors.
fix
Either provide a plain user pool ID string or use a processor object as shown in the configuration example.
affects: >=1.0
Errors
Common errors & fixes
Error: Cannot find module 'dm-driver-cognito'
The package is not installed or not resolvable from the project root.
fix
Run 'npm install dm-driver-cognito' and ensure node_modules contains the package.
TypeError: cognitoDriver is not a constructor
Incorrect import style; the driver should be passed as a value to the 'driver' config field, not instantiated.
fix
Use driver: require('dm-driver-cognito'), not new (require('dm-driver-cognito'))().
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies
data-migrationrequiredCore framework dependency; this package is a driver plugin for data-migration.
@aws-sdk/client-cognito-identity-providerrequiredAWS SDK for Cognito Identity Provider operations.
Agent activity
12 hits · last 30 days
node
8
Resources
dm-driver-cognito — npm install dm-driver-cognito · libregistry