A Data Migration driver to run queries on an Aurora RDS instance.
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 |
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",
},
},
},
},
},
},
},
};
Executes a query against the database, returning a rxjs
Observable
Name | Description |
---|---|
query | The query string to be executed |
parameters | An array of AWS.RDSDataService.SqlParameter s that will be used in the query |
options | A QueryOptions object |
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();
},
};