{"id":8001,"library":"cdk-aurora-globaldatabase","title":"cdk-aurora-globaldatabase","description":"cdk-aurora-globaldatabase is an AWS CDK construct library, currently at version 2.4.18, that simplifies the creation of cross-region AWS Aurora Global Databases. It provides high-level constructs to deploy Aurora clusters across different regions, manage replication, and handle failover scenarios, following the AWS CDK v2 best practices. The library's release cadence generally aligns with updates to the AWS CDK and underlying AWS Aurora features.","status":"active","version":"2.4.18","language":"en","source_language":"en","source_url":"https://github.com/neilkuan/cdk-aurora-globaldatabase.git","tags":["aws","cdk","aurora","rds","global-database","multi-region","python"],"install":[{"cmd":"pip install cdk-aurora-globaldatabase","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core AWS CDK constructs required for deployment, this library is built on CDK v2.","package":"aws-cdk-lib","optional":false},{"reason":"CDK's fundamental construct library dependency, version >=10.0.0 for CDK v2.","package":"constructs","optional":false},{"reason":"Requires Python 3.9 or higher.","package":"python","optional":false}],"imports":[{"symbol":"AuroraGlobalDatabase","correct":"from cdk_aurora_globaldatabase import AuroraGlobalDatabase"}],"quickstart":{"code":"import os\nfrom aws_cdk import App, Stack, Environment\nfrom aws_cdk import aws_ec2 as ec2\nfrom aws_cdk import aws_rds as rds\nfrom cdk_aurora_globaldatabase import AuroraGlobalDatabase\n\nclass GlobalDatabaseStack(Stack):\n    def __init__(self, scope: App, id: str, **kwargs) -> None:\n        super().__init__(scope, id, **kwargs)\n\n        # For a quickstart, we create a new VPC. In a production environment,\n        # you would typically look up an existing VPC: \n        # vpc = ec2.Vpc.from_lookup(self, \"MyExistingVpc\", vpc_name=\"YourVpcName\")\n        vpc = ec2.Vpc(\n            self, \"AuroraGlobalDbVpc\",\n            max_azs=2,  # Deploy resources across 2 availability zones\n            cidr=\"10.0.0.0/16\",\n            enable_dns_hostnames=True,\n            enable_dns_support=True\n        )\n\n        AuroraGlobalDatabase(\n            self, \"MyAuroraGlobalDatabase\",\n            primary_region=\"us-east-1\",\n            secondary_regions=[\"us-east-2\"], # Add more regions as needed\n            aurora_version=rds.AuroraMysqlEngineVersion.VER_3_06_0, # Example MySQL version\n            vpc=vpc,\n            # Optional: specify instance type, credentials, storage encryption, etc.\n            # instance_type=ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.LARGE),\n            # credentials=rds.Credentials.from_generated_secret(\"auroraglobaladmin\"),\n            # encryption_key=kms.Key(self, \"AuroraKey\")\n        )\n\napp = App()\n# Define an environment for the primary stack\nprimary_env = Environment(\n    account=os.environ.get('CDK_DEFAULT_ACCOUNT', '123456789012'),\n    region=os.environ.get('CDK_DEFAULT_REGION', 'us-east-1')\n)\nGlobalDatabaseStack(app, \"AuroraGlobalDbStack\", env=primary_env)\napp.synth()","lang":"python","description":"This quickstart deploys an AWS Aurora Global Database with a MySQL-compatible engine across two AWS regions. It provisions a new VPC for the database. Before running, ensure your AWS account is bootstrapped for CDK in 'us-east-1' and 'us-east-2', and your `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` environment variables are set, or replace the placeholder values. The `synth` command generates the CloudFormation templates."},"warnings":[{"fix":"Migrate your CDK project to AWS CDK v2 by installing `aws-cdk-lib` and `constructs>=10.0.0`. If you must use CDK v1, look for a v1-compatible version of this construct or implement it manually.","message":"This library is built specifically for AWS CDK v2. Attempting to use it with an AWS CDK v1 project will result in `ModuleNotFoundError` for `aws_cdk` or `constructs` (v1 vs v2 imports) or incompatible API usage.","severity":"breaking","affected_versions":"2.x.x (when used with AWS CDK v1)"},{"fix":"Before deploying, run `cdk bootstrap aws://YOUR_ACCOUNT_ID/PRIMARY_REGION` and `cdk bootstrap aws://YOUR_ACCOUNT_ID/SECONDARY_REGION` for every region involved in your global database. Replace `YOUR_ACCOUNT_ID` and region placeholders with your actual AWS account ID and region names.","message":"Deploying an Aurora Global Database across multiple regions requires your AWS environment to be bootstrapped in *all* specified regions (primary and all secondaries).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your AWS CLI or SDK configuration (e.g., `~/.aws/credentials` file, environment variables like `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`) provides valid credentials for all regions where the global database will be deployed. This often means having a profile configured for each region or using global credentials with appropriate permissions.","message":"AWS credentials must be configured for all regions specified in `primary_region` and `secondary_regions`. CDK will attempt to deploy resources in each of these regions.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install cdk-aurora-globaldatabase` to install the library. Ensure your import statement is `from cdk_aurora_globaldatabase import AuroraGlobalDatabase`.","cause":"The library is not installed or the import path is incorrect.","error":"ModuleNotFoundError: No module named 'cdk_aurora_globaldatabase'"},{"fix":"Rename the argument from `primaryRegion` to `primary_region` and apply similar changes for other properties like `secondaryRegions` to `secondary_regions`.","cause":"CDK Python constructs use snake_case for property names (e.g., `primary_region`) instead of camelCase (`primaryRegion`). This is a common mistake when translating from TypeScript/JavaScript examples.","error":"TypeError: __init__() got an unexpected keyword argument 'primaryRegion'"},{"fix":"Ensure you have run `cdk bootstrap aws://YOUR_ACCOUNT_ID/us-east-1` and `cdk bootstrap aws://YOUR_ACCOUNT_ID/us-east-2` (and any other secondary regions). Verify your AWS credentials can access all these regions and have the necessary permissions for RDS, EC2, KMS, etc.","cause":"CDK cross-region deployments require explicit bootstrapping for all regions involved and valid AWS credentials for each. The error can manifest if bootstrapping is incomplete or credentials lack permissions.","error":"Failed to deploy stack 'AuroraGlobalDbStack' because the primary region 'us-east-1' or secondary region 'us-east-2' is not correctly bootstrapped or lacks credentials."}]}