[![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/fb/2c/4b16956b9be00452d08f1afb3ce15fec2077d2c03b906ee55fb0297b2549/cdk_aurora_globaldatabase-2.3.693.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.693",
"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": "db38d4dbd83905aae9261883f89806870f2e73d43bf3d220d72c01bc0c9abecd",
"md5": "56ea99bd3bb3ca857c7752bc4c146ae4",
"sha256": "fcb5e2ff396fd11136af8319107f511f8914ea8e6ab844119c04cf912668e1de"
},
"downloads": -1,
"filename": "cdk_aurora_globaldatabase-2.3.693-py3-none-any.whl",
"has_sig": false,
"md5_digest": "56ea99bd3bb3ca857c7752bc4c146ae4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 75173,
"upload_time": "2024-12-22T00:37:31",
"upload_time_iso_8601": "2024-12-22T00:37:31.559065Z",
"url": "https://files.pythonhosted.org/packages/db/38/d4dbd83905aae9261883f89806870f2e73d43bf3d220d72c01bc0c9abecd/cdk_aurora_globaldatabase-2.3.693-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fb2c4b16956b9be00452d08f1afb3ce15fec2077d2c03b906ee55fb0297b2549",
"md5": "94deea8916b2067a25ab0b6bb7d2fb05",
"sha256": "97bce1ca44118eb5dfe8da8a30df342c73896001f5fa67707e3c2b54ee62ecae"
},
"downloads": -1,
"filename": "cdk_aurora_globaldatabase-2.3.693.tar.gz",
"has_sig": false,
"md5_digest": "94deea8916b2067a25ab0b6bb7d2fb05",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 76869,
"upload_time": "2024-12-22T00:37:35",
"upload_time_iso_8601": "2024-12-22T00:37:35.334847Z",
"url": "https://files.pythonhosted.org/packages/fb/2c/4b16956b9be00452d08f1afb3ce15fec2077d2c03b906ee55fb0297b2549/cdk_aurora_globaldatabase-2.3.693.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-22 00:37:35",
"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"
}