@c3l/relational-database
v1.3.1
Published
This is a basic CDK construct for deploying an old school relational database.
Downloads
4
Readme
C3L: Relational Database
This is a basic CDK construct for deploying an old school relational database.
Please refer to general C3L documentation here.
Install this package:
npm i @c3l/relational-database
The following shows a sample usage, using @c3l/three-tier-vpc as underlying network and storing a generated password in SSM:
import aws = require('aws-sdk');
import cdk = require('@aws-cdk/cdk');
import { ThreeTierVpc } from '@c3l/three-tier-vpc';
import { RelationalDatabase } from '../lib/relational-database';
export class TestStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// Create random RDS password and store in SSM
const key = '/rds/database/master-password';
var params = {
Name: key,
Type: 'SecureString',
Value: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
Overwrite: true
};
var ssm = new aws.SSM({apiVersion: '2014-11-06', region: this.env.region});
ssm.putParameter(params, function(err: any) {
if (err) console.log(err, err.stack);
});
// Create network
const network = new ThreeTierVpc(this, 'DatabaseNetwork',{});
new RelationalDatabase(this, 'RelationalDatabase', {
network: network.vpc,
passwordKeySSM: key,
passwordVersionSSM: 1
});
}
}