cdk-aurora-globaldatabase


Namecdk-aurora-globaldatabase JSON
Version 2.3.475 PyPI version JSON
download
home_pagehttps://github.com/neilkuan/cdk-aurora-globaldatabase.git
Summarycdk-aurora-globaldatabase is an AWS CDK construct library that provides Cross Region Create Global Aurora RDS Databases.
upload_time2024-04-26 00:28:24
maintainerNone
docs_urlNone
authorNeil Kuan<guan840912@gmail.com>
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![NPM version](https://badge.fury.io/js/cdk-aurora-globaldatabase.svg)](https://badge.fury.io/js/cdk-aurora-globaldatabase)
[![PyPI version](https://badge.fury.io/py/cdk-aurora-globaldatabase.svg)](https://badge.fury.io/py/cdk-aurora-globaldatabase)
![Release](https://github.com/neilkuan/cdk-aurora-globaldatabase/workflows/release/badge.svg)

![Downloads](https://img.shields.io/badge/-DOWNLOADS:-brightgreen?color=gray)
![npm](https://img.shields.io/npm/dt/cdk-aurora-globaldatabase?label=npm&color=orange)
![PyPI](https://img.shields.io/pypi/dm/cdk-aurora-globaldatabase?label=pypi&color=blue)

# cdk-aurora-globaldatabase

`cdk-aurora-globaldatabase` is an AWS CDK construct library that allows you to create [Amazon Aurora Global Databases](https://aws.amazon.com/rds/aurora/global-database/) with AWS CDK in Typescript or Python.

# Why

**Amazon Aurora Global Databases** is designed for multi-regional Amazon Aurora Database clusters that span across different AWS regions. Due to the lack of native cloudformation support, it has been very challenging to build with cloudformation or AWS CDK with the upstream `aws-rds` construct.

`cdk-aurora-globaldatabase` aims to offload the heavy-lifting and helps you provision and deploy cross-regional **Amazon Aurora Global Databases** simply with just a few CDK statements.

## Install

```bash
Use the npm dist tag to opt in CDKv1 or CDKv2:

// for CDKv2
npm install cdk-aurora-globaldatabase
or
npm install cdk-aurora-globaldatabase@latest

// for CDKv1
npm install cdk-aurora-globaldatabase@cdkv1
```

# ⛔️ Please do not use cdk v1, because lot of db engine version already not been update in @aws-cdk/aws-rds upstream. ⛔️

## Now Try It !!!

# Sample for Mysql

```python
import { GlobalAuroraRDSMaster, InstanceTypeEnum, GlobalAuroraRDSSlaveInfra } from 'cdk-aurora-globaldatabase';
import { App, Stack, CfnOutput } from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
// new app .
const mockApp = new App();

// setting two region env config .
const envSingapro  = { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-southeast-1' };
const envTokyo = { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-northeast-1' };

// create stack main .
const stackM = new Stack(mockApp, 'testing-stackM',{env: envTokyo});
const vpcPublic = new ec2.Vpc(stackM,'defaultVpc',{
  natGateways: 0,
  maxAzs: 3,
  subnetConfiguration: [{
    cidrMask: 26,
    name: 'masterVPC2',
    subnetType: ec2.SubnetType.PUBLIC,
  }],
});
const  globaldbM = new GlobalAuroraRDSMaster(stackM, 'globalAuroraRDSMaster',{
  instanceType: InstanceTypeEnum.R5_LARGE,
  vpc: vpcPublic,
  rdsPassword: '1qaz2wsx',
});
globaldbM.rdsCluster.connections.allowDefaultPortFrom(ec2.Peer.ipv4(`${process.env.MYIP}/32`))

// create stack slave infra or you can give your subnet group.
const stackS = new Stack(mockApp, 'testing-stackS',{env: envSingapro});
const vpcPublic2 = new ec2.Vpc(stackS,'defaultVpc2',{
  natGateways: 0,
  maxAzs: 3,
  subnetConfiguration: [{
    cidrMask: 26,
    name: 'secondVPC2',
    subnetType: ec2.SubnetType.PUBLIC,
  }],
});
const globaldbS = new GlobalAuroraRDSSlaveInfra(stackS, 'slaveregion',{vpc: vpcPublic2,subnetType:ec2.SubnetType.PUBLIC });

// so we need to wait stack slave created first .
stackM.addDependency(stackS)


new CfnOutput(stackM, 'password', { value: globaldbM.rdsPassword });
// add second region cluster
globaldbM.addRegionalCluster(stackM,'addregionalrds',{
  region: 'ap-southeast-1',
  dbSubnetGroupName: globaldbS.dbSubnetGroup.dbSubnetGroupName,
});
```

![like this ](./image/Mysql-cluster.jpg)

# Sample for Postgres

```python
import { GlobalAuroraRDSMaster, InstanceTypeEnum, GlobalAuroraRDSSlaveInfra } from 'cdk-aurora-globaldatabase';
import { App, Stack, CfnOutput } from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as _rds from 'aws-cdk-lib/aws-rds';

const mockApp = new App();
const envSingapro  = { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-southeast-1' };
const envTokyo = { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-northeast-1' };

const stackM = new Stack(mockApp, 'testing-stackM',{env: envTokyo});
const vpcPublic = new ec2.Vpc(stackM,'defaultVpc',{
  natGateways: 0,
  maxAzs: 3,
  subnetConfiguration: [{
    cidrMask: 26,
    name: 'masterVPC2',
    subnetType: ec2.SubnetType.PUBLIC,
  }],
});

// Note if you use postgres , need to give the same value in engineVersion and  dbClusterpPG's engine .
const globaldbM = new GlobalAuroraRDSMaster(stackM, 'globalAuroraRDSMaster',{
  instanceType: InstanceTypeEnum.R5_LARGE,
  vpc: vpcPublic,
  rdsPassword: '1qaz2wsx',
  engineVersion: _rds.DatabaseClusterEngine.auroraPostgres({
    version: _rds.AuroraPostgresEngineVersion.VER_12_11}),
  dbClusterpPG: new _rds.ParameterGroup(stackM, 'dbClusterparametergroup', {
    engine: _rds.DatabaseClusterEngine.auroraPostgres({
      version: _rds.AuroraPostgresEngineVersion.VER_12_11,
    }),
    parameters: {
      'rds.force_ssl': '1',
      'rds.log_retention_period': '10080',
      'auto_explain.log_min_duration': '5000',
      'auto_explain.log_verbose': '1',
      'timezone': 'UTC+8',
      'shared_preload_libraries': 'auto_explain,pg_stat_statements,pg_hint_plan,pgaudit',
      'log_connections': '1',
      'log_statement': 'ddl',
      'log_disconnections': '1',
      'log_lock_waits': '1',
      'log_min_duration_statement': '5000',
      'log_rotation_age': '1440',
      'log_rotation_size': '102400',
      'random_page_cost': '1',
      'track_activity_query_size': '16384',
      'idle_in_transaction_session_timeout': '7200000',
    },
  }),
});
globaldbM.rdsCluster.connections.allowDefaultPortFrom(ec2.Peer.ipv4(`${process.env.MYIP}/32`))

const stackS = new Stack(mockApp, 'testing-stackS',{env: envSingapro});
const vpcPublic2 = new ec2.Vpc(stackS,'defaultVpc2',{
  natGateways: 0,
  maxAzs: 3,
  subnetConfiguration: [{
    cidrMask: 26,
    name: 'secondVPC2',
    subnetType: ec2.SubnetType.PUBLIC,
  }],
});
const globaldbS = new GlobalAuroraRDSSlaveInfra(stackS, 'slaveregion',{
  vpc: vpcPublic2,subnetType:ec2.SubnetType.PUBLIC,
});

stackM.addDependency(stackS)


new CfnOutput(stackM, 'password', { value: globaldbM.rdsPassword });
// add second region cluster
globaldbM.addRegionalCluster(stackM,'addregionalrds',{
  region: 'ap-southeast-1',
  dbSubnetGroupName: globaldbS.dbSubnetGroup.dbSubnetGroupName,
});
```

### To deploy

```bash
cdk deploy
```

### To destroy

```bash
cdk destroy
```

## :clap:  Supporters

[![Stargazers repo roster for @neilkuan/cdk-aurora-globaldatabase](https://reporoster.com/stars/neilkuan/cdk-aurora-globaldatabase)](https://github.com/neilkuan/cdk-aurora-globaldatabase/stargazers)
[![Forkers repo roster for @neilkuan/cdk-aurora-globaldatabase](https://reporoster.com/forks/neilkuan/cdk-aurora-globaldatabase)](https://github.com/neilkuan/cdk-aurora-globaldatabase/network/members)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/neilkuan/cdk-aurora-globaldatabase.git",
    "name": "cdk-aurora-globaldatabase",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Neil Kuan<guan840912@gmail.com>",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/42/22/ab2afdd1f317a339abd8a100d52f201a5dccc9d311d31eb067e864746a7a/cdk-aurora-globaldatabase-2.3.475.tar.gz",
    "platform": null,
    "description": "[![NPM version](https://badge.fury.io/js/cdk-aurora-globaldatabase.svg)](https://badge.fury.io/js/cdk-aurora-globaldatabase)\n[![PyPI version](https://badge.fury.io/py/cdk-aurora-globaldatabase.svg)](https://badge.fury.io/py/cdk-aurora-globaldatabase)\n![Release](https://github.com/neilkuan/cdk-aurora-globaldatabase/workflows/release/badge.svg)\n\n![Downloads](https://img.shields.io/badge/-DOWNLOADS:-brightgreen?color=gray)\n![npm](https://img.shields.io/npm/dt/cdk-aurora-globaldatabase?label=npm&color=orange)\n![PyPI](https://img.shields.io/pypi/dm/cdk-aurora-globaldatabase?label=pypi&color=blue)\n\n# cdk-aurora-globaldatabase\n\n`cdk-aurora-globaldatabase` is an AWS CDK construct library that allows you to create [Amazon Aurora Global Databases](https://aws.amazon.com/rds/aurora/global-database/) with AWS CDK in Typescript or Python.\n\n# Why\n\n**Amazon Aurora Global Databases** is designed for multi-regional Amazon Aurora Database clusters that span across different AWS regions. Due to the lack of native cloudformation support, it has been very challenging to build with cloudformation or AWS CDK with the upstream `aws-rds` construct.\n\n`cdk-aurora-globaldatabase` aims to offload the heavy-lifting and helps you provision and deploy cross-regional **Amazon Aurora Global Databases** simply with just a few CDK statements.\n\n## Install\n\n```bash\nUse the npm dist tag to opt in CDKv1 or CDKv2:\n\n// for CDKv2\nnpm install cdk-aurora-globaldatabase\nor\nnpm install cdk-aurora-globaldatabase@latest\n\n// for CDKv1\nnpm install cdk-aurora-globaldatabase@cdkv1\n```\n\n# \u26d4\ufe0f Please do not use cdk v1, because lot of db engine version already not been update in @aws-cdk/aws-rds upstream. \u26d4\ufe0f\n\n## Now Try It !!!\n\n# Sample for Mysql\n\n```python\nimport { GlobalAuroraRDSMaster, InstanceTypeEnum, GlobalAuroraRDSSlaveInfra } from 'cdk-aurora-globaldatabase';\nimport { App, Stack, CfnOutput } from 'aws-cdk-lib';\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\n// new app .\nconst mockApp = new App();\n\n// setting two region env config .\nconst envSingapro  = { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-southeast-1' };\nconst envTokyo = { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-northeast-1' };\n\n// create stack main .\nconst stackM = new Stack(mockApp, 'testing-stackM',{env: envTokyo});\nconst vpcPublic = new ec2.Vpc(stackM,'defaultVpc',{\n  natGateways: 0,\n  maxAzs: 3,\n  subnetConfiguration: [{\n    cidrMask: 26,\n    name: 'masterVPC2',\n    subnetType: ec2.SubnetType.PUBLIC,\n  }],\n});\nconst  globaldbM = new GlobalAuroraRDSMaster(stackM, 'globalAuroraRDSMaster',{\n  instanceType: InstanceTypeEnum.R5_LARGE,\n  vpc: vpcPublic,\n  rdsPassword: '1qaz2wsx',\n});\nglobaldbM.rdsCluster.connections.allowDefaultPortFrom(ec2.Peer.ipv4(`${process.env.MYIP}/32`))\n\n// create stack slave infra or you can give your subnet group.\nconst stackS = new Stack(mockApp, 'testing-stackS',{env: envSingapro});\nconst vpcPublic2 = new ec2.Vpc(stackS,'defaultVpc2',{\n  natGateways: 0,\n  maxAzs: 3,\n  subnetConfiguration: [{\n    cidrMask: 26,\n    name: 'secondVPC2',\n    subnetType: ec2.SubnetType.PUBLIC,\n  }],\n});\nconst globaldbS = new GlobalAuroraRDSSlaveInfra(stackS, 'slaveregion',{vpc: vpcPublic2,subnetType:ec2.SubnetType.PUBLIC });\n\n// so we need to wait stack slave created first .\nstackM.addDependency(stackS)\n\n\nnew CfnOutput(stackM, 'password', { value: globaldbM.rdsPassword });\n// add second region cluster\nglobaldbM.addRegionalCluster(stackM,'addregionalrds',{\n  region: 'ap-southeast-1',\n  dbSubnetGroupName: globaldbS.dbSubnetGroup.dbSubnetGroupName,\n});\n```\n\n![like this ](./image/Mysql-cluster.jpg)\n\n# Sample for Postgres\n\n```python\nimport { GlobalAuroraRDSMaster, InstanceTypeEnum, GlobalAuroraRDSSlaveInfra } from 'cdk-aurora-globaldatabase';\nimport { App, Stack, CfnOutput } from 'aws-cdk-lib';\nimport * as ec2 from 'aws-cdk-lib/aws-ec2';\nimport * as _rds from 'aws-cdk-lib/aws-rds';\n\nconst mockApp = new App();\nconst envSingapro  = { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-southeast-1' };\nconst envTokyo = { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-northeast-1' };\n\nconst stackM = new Stack(mockApp, 'testing-stackM',{env: envTokyo});\nconst vpcPublic = new ec2.Vpc(stackM,'defaultVpc',{\n  natGateways: 0,\n  maxAzs: 3,\n  subnetConfiguration: [{\n    cidrMask: 26,\n    name: 'masterVPC2',\n    subnetType: ec2.SubnetType.PUBLIC,\n  }],\n});\n\n// Note if you use postgres , need to give the same value in engineVersion and  dbClusterpPG's engine .\nconst globaldbM = new GlobalAuroraRDSMaster(stackM, 'globalAuroraRDSMaster',{\n  instanceType: InstanceTypeEnum.R5_LARGE,\n  vpc: vpcPublic,\n  rdsPassword: '1qaz2wsx',\n  engineVersion: _rds.DatabaseClusterEngine.auroraPostgres({\n    version: _rds.AuroraPostgresEngineVersion.VER_12_11}),\n  dbClusterpPG: new _rds.ParameterGroup(stackM, 'dbClusterparametergroup', {\n    engine: _rds.DatabaseClusterEngine.auroraPostgres({\n      version: _rds.AuroraPostgresEngineVersion.VER_12_11,\n    }),\n    parameters: {\n      'rds.force_ssl': '1',\n      'rds.log_retention_period': '10080',\n      'auto_explain.log_min_duration': '5000',\n      'auto_explain.log_verbose': '1',\n      'timezone': 'UTC+8',\n      'shared_preload_libraries': 'auto_explain,pg_stat_statements,pg_hint_plan,pgaudit',\n      'log_connections': '1',\n      'log_statement': 'ddl',\n      'log_disconnections': '1',\n      'log_lock_waits': '1',\n      'log_min_duration_statement': '5000',\n      'log_rotation_age': '1440',\n      'log_rotation_size': '102400',\n      'random_page_cost': '1',\n      'track_activity_query_size': '16384',\n      'idle_in_transaction_session_timeout': '7200000',\n    },\n  }),\n});\nglobaldbM.rdsCluster.connections.allowDefaultPortFrom(ec2.Peer.ipv4(`${process.env.MYIP}/32`))\n\nconst stackS = new Stack(mockApp, 'testing-stackS',{env: envSingapro});\nconst vpcPublic2 = new ec2.Vpc(stackS,'defaultVpc2',{\n  natGateways: 0,\n  maxAzs: 3,\n  subnetConfiguration: [{\n    cidrMask: 26,\n    name: 'secondVPC2',\n    subnetType: ec2.SubnetType.PUBLIC,\n  }],\n});\nconst globaldbS = new GlobalAuroraRDSSlaveInfra(stackS, 'slaveregion',{\n  vpc: vpcPublic2,subnetType:ec2.SubnetType.PUBLIC,\n});\n\nstackM.addDependency(stackS)\n\n\nnew CfnOutput(stackM, 'password', { value: globaldbM.rdsPassword });\n// add second region cluster\nglobaldbM.addRegionalCluster(stackM,'addregionalrds',{\n  region: 'ap-southeast-1',\n  dbSubnetGroupName: globaldbS.dbSubnetGroup.dbSubnetGroupName,\n});\n```\n\n### To deploy\n\n```bash\ncdk deploy\n```\n\n### To destroy\n\n```bash\ncdk destroy\n```\n\n## :clap:  Supporters\n\n[![Stargazers repo roster for @neilkuan/cdk-aurora-globaldatabase](https://reporoster.com/stars/neilkuan/cdk-aurora-globaldatabase)](https://github.com/neilkuan/cdk-aurora-globaldatabase/stargazers)\n[![Forkers repo roster for @neilkuan/cdk-aurora-globaldatabase](https://reporoster.com/forks/neilkuan/cdk-aurora-globaldatabase)](https://github.com/neilkuan/cdk-aurora-globaldatabase/network/members)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "cdk-aurora-globaldatabase is an AWS CDK construct library that provides Cross Region Create Global Aurora RDS Databases.",
    "version": "2.3.475",
    "project_urls": {
        "Homepage": "https://github.com/neilkuan/cdk-aurora-globaldatabase.git",
        "Source": "https://github.com/neilkuan/cdk-aurora-globaldatabase.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24bdd02566e9d46751cf4c7a7177086fbdee1b550b93e8557299d1b876756dd7",
                "md5": "09b6b771605703bf4c0edcad17f087fe",
                "sha256": "f6b63ed6b68c987b880a02c314d507e94e9f01d3a95a2706313633ef8e7f6ee7"
            },
            "downloads": -1,
            "filename": "cdk_aurora_globaldatabase-2.3.475-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "09b6b771605703bf4c0edcad17f087fe",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 70318,
            "upload_time": "2024-04-26T00:28:10",
            "upload_time_iso_8601": "2024-04-26T00:28:10.290889Z",
            "url": "https://files.pythonhosted.org/packages/24/bd/d02566e9d46751cf4c7a7177086fbdee1b550b93e8557299d1b876756dd7/cdk_aurora_globaldatabase-2.3.475-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4222ab2afdd1f317a339abd8a100d52f201a5dccc9d311d31eb067e864746a7a",
                "md5": "91f90e42ab8be7c4f11845a404458407",
                "sha256": "2decac27705bccdb55094442fe09ee4ef661539ade1cd1ea2b3b3ea202913919"
            },
            "downloads": -1,
            "filename": "cdk-aurora-globaldatabase-2.3.475.tar.gz",
            "has_sig": false,
            "md5_digest": "91f90e42ab8be7c4f11845a404458407",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 72298,
            "upload_time": "2024-04-26T00:28:24",
            "upload_time_iso_8601": "2024-04-26T00:28:24.079069Z",
            "url": "https://files.pythonhosted.org/packages/42/22/ab2afdd1f317a339abd8a100d52f201a5dccc9d311d31eb067e864746a7a/cdk-aurora-globaldatabase-2.3.475.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-26 00:28:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "neilkuan",
    "github_project": "cdk-aurora-globaldatabase",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cdk-aurora-globaldatabase"
}
        
Elapsed time: 0.41552s