cdk-aurora-globaldatabase


Namecdk-aurora-globaldatabase JSON
Version 0.1.79 PyPI version JSON
download
home_pagehttps://github.com/guan840912/cdk-aurora-globaldatabase.git
Summarycdk-aurora-globaldatabase is an AWS CDK construct library that provides Cross Region Create Global Aurora RDS Databases.
upload_time2021-01-16 02:05:37
maintainer
docs_urlNone
authorNeil Kuan<guan840912@gmail.com>
requires_python>=3.6
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/guan840912/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.

## Now Try It !!!

# Sample for Mysql

```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from ..index import GolbalAuroraRDSMaster, InstanceTypeEnum, GolbalAuroraRDSSlaveInfra
from aws_cdk.core import App, Stack, CfnOutput
import aws_cdk.aws_ec2 as ec2
# new app .
mock_app = App()

# setting two region env config .
env_singapro = {"account": process.env.CDK_DEFAULT_ACCOUNT, "region": "ap-southeast-1"}
env_tokyo = {"account": process.env.CDK_DEFAULT_ACCOUNT, "region": "ap-northeast-1"}

# create stack main .
stack_m = Stack(mock_app, "testing-stackM", env=env_tokyo)
vpc_public = ec2.Vpc(stack_m, "defaultVpc",
    nat_gateways=0,
    max_azs=3,
    subnet_configuration=[SubnetConfiguration(
        cidr_mask=26,
        name="masterVPC2",
        subnet_type=ec2.SubnetType.PUBLIC
    )]
)
globaldb_m = GolbalAuroraRDSMaster(stack_m, "golbalAuroraRDSMaster",
    instance_type=InstanceTypeEnum.R5_LARGE,
    vpc=vpc_public,
    rds_password="1qaz2wsx"
)
globaldb_m.rds_cluster.connections.allow_default_port_from(ec2.Peer.ipv4(f"{process.env.MYIP}/32"))

# create stack slave infra or you can give your subnet group.
stack_s = Stack(mock_app, "testing-stackS", env=env_singapro)
vpc_public2 = ec2.Vpc(stack_s, "defaultVpc2",
    nat_gateways=0,
    max_azs=3,
    subnet_configuration=[SubnetConfiguration(
        cidr_mask=26,
        name="secondVPC2",
        subnet_type=ec2.SubnetType.PUBLIC
    )]
)
globaldb_s = GolbalAuroraRDSSlaveInfra(stack_s, "slaveregion", vpc=vpc_public2, subnet_type=ec2.SubnetType.PUBLIC)

# so we need to wait stack slave created first .
stack_m.add_dependency(stack_s)

CfnOutput(stack_m, "password", value=globaldb_m.rds_password)
# add second region cluster
globaldb_m.add_regional_cluster(stack_m, "addregionalrds",
    region="ap-southeast-1",
    db_subnet_group_name=globaldb_s.db_subnet_group.db_subnet_group_name
)
```

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

# Sample for Postgres

```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from ..index import GolbalAuroraRDSMaster, InstanceTypeEnum, GolbalAuroraRDSSlaveInfra
from aws_cdk.core import App, Stack, CfnOutput
import aws_cdk.aws_ec2 as ec2
import aws_cdk.aws_rds as _rds

mock_app = App()
env_singapro = {"account": process.env.CDK_DEFAULT_ACCOUNT, "region": "ap-southeast-1"}
env_tokyo = {"account": process.env.CDK_DEFAULT_ACCOUNT, "region": "ap-northeast-1"}

stack_m = Stack(mock_app, "testing-stackM", env=env_tokyo)
vpc_public = ec2.Vpc(stack_m, "defaultVpc",
    nat_gateways=0,
    max_azs=3,
    subnet_configuration=[SubnetConfiguration(
        cidr_mask=26,
        name="masterVPC2",
        subnet_type=ec2.SubnetType.PUBLIC
    )]
)

# Note if you use postgres , need to give the same value in engineVersion and  dbClusterpPG's engine .
globaldb_m = GolbalAuroraRDSMaster(stack_m, "golbalAuroraRDSMaster",
    instance_type=InstanceTypeEnum.R5_LARGE,
    vpc=vpc_public,
    rds_password="1qaz2wsx",
    engine_version=_rds.DatabaseClusterEngine.aurora_postgres(
        version=_rds.AuroraPostgresEngineVersion.VER_11_7
    ),
    db_clusterp_pG=_rds.ParameterGroup(stack_m, "dbClusterparametergroup",
        engine=_rds.DatabaseClusterEngine.aurora_postgres(
            version=_rds.AuroraPostgresEngineVersion.VER_11_7
        ),
        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"
        }
    )
)
globaldb_m.rds_cluster.connections.allow_default_port_from(ec2.Peer.ipv4(f"{process.env.MYIP}/32"))

stack_s = Stack(mock_app, "testing-stackS", env=env_singapro)
vpc_public2 = ec2.Vpc(stack_s, "defaultVpc2",
    nat_gateways=0,
    max_azs=3,
    subnet_configuration=[SubnetConfiguration(
        cidr_mask=26,
        name="secondVPC2",
        subnet_type=ec2.SubnetType.PUBLIC
    )]
)
globaldb_s = GolbalAuroraRDSSlaveInfra(stack_s, "slaveregion",
    vpc=vpc_public2, subnet_type=ec2.SubnetType.PUBLIC
)

stack_m.add_dependency(stack_s)

CfnOutput(stack_m, "password", value=globaldb_m.rds_password)
# add second region cluster
globaldb_m.add_regional_cluster(stack_m, "addregionalrds",
    region="ap-southeast-1",
    db_subnet_group_name=globaldb_s.db_subnet_group.db_subnet_group_name
)
```

### To deploy

```bash
cdk deploy
```

### To destroy

```bash
cdk destroy
```

## :clap:  Supporters

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



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/guan840912/cdk-aurora-globaldatabase.git",
    "name": "cdk-aurora-globaldatabase",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Neil Kuan<guan840912@gmail.com>",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/92/d9/823a09203352414609e07b7200b532681ac5e19edd5dc9fcde6324969869/cdk-aurora-globaldatabase-0.1.79.tar.gz",
    "platform": "",
    "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/guan840912/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## Now Try It !!!\n\n# Sample for Mysql\n\n```python\n# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826\nfrom ..index import GolbalAuroraRDSMaster, InstanceTypeEnum, GolbalAuroraRDSSlaveInfra\nfrom aws_cdk.core import App, Stack, CfnOutput\nimport aws_cdk.aws_ec2 as ec2\n# new app .\nmock_app = App()\n\n# setting two region env config .\nenv_singapro = {\"account\": process.env.CDK_DEFAULT_ACCOUNT, \"region\": \"ap-southeast-1\"}\nenv_tokyo = {\"account\": process.env.CDK_DEFAULT_ACCOUNT, \"region\": \"ap-northeast-1\"}\n\n# create stack main .\nstack_m = Stack(mock_app, \"testing-stackM\", env=env_tokyo)\nvpc_public = ec2.Vpc(stack_m, \"defaultVpc\",\n    nat_gateways=0,\n    max_azs=3,\n    subnet_configuration=[SubnetConfiguration(\n        cidr_mask=26,\n        name=\"masterVPC2\",\n        subnet_type=ec2.SubnetType.PUBLIC\n    )]\n)\nglobaldb_m = GolbalAuroraRDSMaster(stack_m, \"golbalAuroraRDSMaster\",\n    instance_type=InstanceTypeEnum.R5_LARGE,\n    vpc=vpc_public,\n    rds_password=\"1qaz2wsx\"\n)\nglobaldb_m.rds_cluster.connections.allow_default_port_from(ec2.Peer.ipv4(f\"{process.env.MYIP}/32\"))\n\n# create stack slave infra or you can give your subnet group.\nstack_s = Stack(mock_app, \"testing-stackS\", env=env_singapro)\nvpc_public2 = ec2.Vpc(stack_s, \"defaultVpc2\",\n    nat_gateways=0,\n    max_azs=3,\n    subnet_configuration=[SubnetConfiguration(\n        cidr_mask=26,\n        name=\"secondVPC2\",\n        subnet_type=ec2.SubnetType.PUBLIC\n    )]\n)\nglobaldb_s = GolbalAuroraRDSSlaveInfra(stack_s, \"slaveregion\", vpc=vpc_public2, subnet_type=ec2.SubnetType.PUBLIC)\n\n# so we need to wait stack slave created first .\nstack_m.add_dependency(stack_s)\n\nCfnOutput(stack_m, \"password\", value=globaldb_m.rds_password)\n# add second region cluster\nglobaldb_m.add_regional_cluster(stack_m, \"addregionalrds\",\n    region=\"ap-southeast-1\",\n    db_subnet_group_name=globaldb_s.db_subnet_group.db_subnet_group_name\n)\n```\n\n![like this ](./image/Mysql-cluster.jpg)\n\n# Sample for Postgres\n\n```python\n# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826\nfrom ..index import GolbalAuroraRDSMaster, InstanceTypeEnum, GolbalAuroraRDSSlaveInfra\nfrom aws_cdk.core import App, Stack, CfnOutput\nimport aws_cdk.aws_ec2 as ec2\nimport aws_cdk.aws_rds as _rds\n\nmock_app = App()\nenv_singapro = {\"account\": process.env.CDK_DEFAULT_ACCOUNT, \"region\": \"ap-southeast-1\"}\nenv_tokyo = {\"account\": process.env.CDK_DEFAULT_ACCOUNT, \"region\": \"ap-northeast-1\"}\n\nstack_m = Stack(mock_app, \"testing-stackM\", env=env_tokyo)\nvpc_public = ec2.Vpc(stack_m, \"defaultVpc\",\n    nat_gateways=0,\n    max_azs=3,\n    subnet_configuration=[SubnetConfiguration(\n        cidr_mask=26,\n        name=\"masterVPC2\",\n        subnet_type=ec2.SubnetType.PUBLIC\n    )]\n)\n\n# Note if you use postgres , need to give the same value in engineVersion and  dbClusterpPG's engine .\nglobaldb_m = GolbalAuroraRDSMaster(stack_m, \"golbalAuroraRDSMaster\",\n    instance_type=InstanceTypeEnum.R5_LARGE,\n    vpc=vpc_public,\n    rds_password=\"1qaz2wsx\",\n    engine_version=_rds.DatabaseClusterEngine.aurora_postgres(\n        version=_rds.AuroraPostgresEngineVersion.VER_11_7\n    ),\n    db_clusterp_pG=_rds.ParameterGroup(stack_m, \"dbClusterparametergroup\",\n        engine=_rds.DatabaseClusterEngine.aurora_postgres(\n            version=_rds.AuroraPostgresEngineVersion.VER_11_7\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)\nglobaldb_m.rds_cluster.connections.allow_default_port_from(ec2.Peer.ipv4(f\"{process.env.MYIP}/32\"))\n\nstack_s = Stack(mock_app, \"testing-stackS\", env=env_singapro)\nvpc_public2 = ec2.Vpc(stack_s, \"defaultVpc2\",\n    nat_gateways=0,\n    max_azs=3,\n    subnet_configuration=[SubnetConfiguration(\n        cidr_mask=26,\n        name=\"secondVPC2\",\n        subnet_type=ec2.SubnetType.PUBLIC\n    )]\n)\nglobaldb_s = GolbalAuroraRDSSlaveInfra(stack_s, \"slaveregion\",\n    vpc=vpc_public2, subnet_type=ec2.SubnetType.PUBLIC\n)\n\nstack_m.add_dependency(stack_s)\n\nCfnOutput(stack_m, \"password\", value=globaldb_m.rds_password)\n# add second region cluster\nglobaldb_m.add_regional_cluster(stack_m, \"addregionalrds\",\n    region=\"ap-southeast-1\",\n    db_subnet_group_name=globaldb_s.db_subnet_group.db_subnet_group_name\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 @guan840912/cdk-aurora-globaldatabase](https://reporoster.com/stars/guan840912/cdk-aurora-globaldatabase)](https://github.com/guan840912/cdk-aurora-globaldatabase/stargazers)\n[![Forkers repo roster for @guan840912/cdk-aurora-globaldatabase](https://reporoster.com/forks/guan840912/cdk-aurora-globaldatabase)](https://github.com/guan840912/cdk-aurora-globaldatabase/network/members)\n\n\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": "0.1.79",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "2d56c46fa96943a95173b25bf29253ce",
                "sha256": "9b46ef3488903478e6e6e4192cc2f8ef8632510431da9a7438f7fe2777f0f200"
            },
            "downloads": -1,
            "filename": "cdk_aurora_globaldatabase-0.1.79-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2d56c46fa96943a95173b25bf29253ce",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 53131,
            "upload_time": "2021-01-16T02:05:36",
            "upload_time_iso_8601": "2021-01-16T02:05:36.243246Z",
            "url": "https://files.pythonhosted.org/packages/66/ac/82b4d697fe726c987983654cf609b7a5677401c2458ad2486802c4ff26e3/cdk_aurora_globaldatabase-0.1.79-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "4b5465150a5ac209f6f120a1bc25ab9d",
                "sha256": "71de6090d79689eb35c51ea81df315c1be4b25b44c6591480bad7a5a556bca11"
            },
            "downloads": -1,
            "filename": "cdk-aurora-globaldatabase-0.1.79.tar.gz",
            "has_sig": false,
            "md5_digest": "4b5465150a5ac209f6f120a1bc25ab9d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 55184,
            "upload_time": "2021-01-16T02:05:37",
            "upload_time_iso_8601": "2021-01-16T02:05:37.696242Z",
            "url": "https://files.pythonhosted.org/packages/92/d9/823a09203352414609e07b7200b532681ac5e19edd5dc9fcde6324969869/cdk-aurora-globaldatabase-0.1.79.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-01-16 02:05:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "guan840912",
    "error": "Could not fetch GitHub repository",
    "lcname": "cdk-aurora-globaldatabase"
}
        
Elapsed time: 0.21349s