@matthewbonig/rds-tools
Version:
A construct for working with RDS SQL servers
62 lines (61 loc) • 2.23 kB
TypeScript
import { aws_ec2 as ec2, aws_lambda, aws_rds, aws_secretsmanager } from 'aws-cdk-lib';
import { Connections, IConnectable } from 'aws-cdk-lib/aws-ec2';
import { Construct } from 'constructs';
export interface DatabaseScriptProps {
/**
* The VPC for the Lambda Function to attach to. If one is not provide, it's assumed from the database instance.
*/
readonly vpc?: ec2.IVpc;
/**
* An optional databaseName. If none is provided then it will be the default for the rds instance, as defined by the AWS docs.
*
* mysql - mysql
* mssql - master
* postgres - postgres
*
*/
readonly databaseName?: string;
/**
* The database instance to run the script against
*/
readonly databaseInstance?: aws_rds.DatabaseInstance;
/**
* An optional secret that provides credentials for the database. Must have fields 'username' and 'password'
*
* @default the root secret from the database instance
*/
readonly secret?: aws_secretsmanager.ISecret;
/**
* The script to execute.
*/
readonly script: string;
/**
* Deploy a second Lambda function that allows for adhoc sql against the database?
*
* @default false
*/
readonly enableAdhoc?: boolean;
}
export declare class DatabaseScript extends Construct implements IConnectable {
/**
* The underlying Lambda handler function for making adhoc commands against the database.
* Undefined unless 'enableAdhoc' is true
*/
adhocHandler?: aws_lambda.IFunction;
readonly handler: aws_lambda.IFunction;
private readonly providerLayer;
constructor(scope: Construct, id: string, props: DatabaseScriptProps);
get connections(): Connections;
get adhocConnections(): Connections;
/**
* Grants access to the Lambda Function to the given SecurityGroup.
* Adds an ingress rule to the given security group and for the given port.
* @deprecated Do not use, pass this construct as an IConnectable
* @param securityGroup
* @param port
*/
bind(securityGroup: ec2.SecurityGroup, port: ec2.Port): DatabaseScript;
slugify(x: string): string;
private createLambda;
private ensureLambda;
}