1.3.2 • Published 5 years ago

@c3l/aurora-serverless v1.3.2

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

C3L: Aurora Serverless

This is a basic CDK construct for deploying a serverless aurora database in a precreated VPC.

Please refer to general C3L documentation here.

Install this package:

npm i @c3l/aurora-serverless

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 { AuroraServerless } from '../lib/aurora-serverless';

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/aurora/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 AuroraServerless(this, 'AuroraServerless', {
      network: network.vpc,
      passwordKeySSM: key,
      passwordVersionSSM: 1
    });
  }
}