Welcome to dm-driver-aurora 👋

Build Status NPM Package Maintainability Documentation Downloads/week lerna

A Data Migration driver to run queries on an Aurora RDS instance.

Configuration

Parameters

The Aurora RDS driver accepts the following parameters as part of its configuration:

Name Type Required Description
region string Yes The AWS Region where this table exists
resourceArn string Yes ARN of the Aruora RDS cluster
secretArn string Yes ARN of the secret manager secret to use for database credentials
profile string No Name of the AWS profile to use
databaseSchema string No The database schema to connect to by default

Example

const CloudFormationProcessor = require("dm-processor-cf");

module.exports = {
  defaultStage: "prod",
  migrationDirectory: "migrations",
  stages: {
    prod: {
      defaultParams: {
        region: "us-east-1",
        stack: "some-stack-name",
      },
      drivers: {
        auroraDriver: {
          driver: require("dm-driver-aurora"),
          params: {
            databaseSchema: "some-schema",
            resourceArn: {
              processor: CloudFormationProcessor,
              params: {
                output: "AuroraArn",
              },
            },
            secretArn: {
              processor: CloudFormationProcessor,
              params: {
                output: "AuroraSecretArn",
              },
            },
          },
        },
      },
    },
  },
};

Methods

query

Executes a query against the database, returning a rxjs Observable

Arguments

Name Description
query The query string to be executed
parameters An array of AWS.RDSDataService.SqlParameters that will be used in the query
options A QueryOptions object

Example

import { toArray } from "rxjs/operators";
import { AuroraRdsDriver } from "dm-driver-aurora";

export default {
  async up(context: ScriptContext, log: Logger) {
    const aurora = await context.getDriver<AuroraRdsDriver>("auroraDriver");
    const someTableResults = await aurora
      .query<SomeDataType>(`SELECT * FROM some_table`)
      .pipe(toArray())
      .toPromise();
  },
};