Package: cdk-aurora-globaldatabase
cdk-aurora-globaldatabasecdk-aurora-globaldatabaseis an AWS CDK construct library that allows you to createAmazon Aurora Global Databaseswith AWS CDK in Typescript or Python.WhyAmazon Aurora Global Databasesis 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 upstreamaws-rdsconstruct.cdk-aurora-globaldatabaseaims to offload the heavy-lifting and helps you provision and deploy cross-regionalAmazon Aurora Global Databasessimply with just a few CDK statements.InstallUsethenpmdisttagtooptinCDKv1orCDKv2:

//forCDKv2
npminstallcdk-aurora-globaldatabase
or
npminstallcdk-aurora-globaldatabase@latest

//forCDKv1
npminstallcdk-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 Mysqlimport{GlobalAuroraRDSMaster,InstanceTypeEnum,GlobalAuroraRDSSlaveInfra}from'cdk-aurora-globaldatabase';import{App,Stack,CfnOutput}from'aws-cdk-lib';import*asec2from'aws-cdk-lib/aws-ec2';//newapp.constmockApp=newApp();//settingtworegionenvconfig.constenvSingapro={account:process.env.CDK_DEFAULT_ACCOUNT,region:'ap-southeast-1'};constenvTokyo={account:process.env.CDK_DEFAULT_ACCOUNT,region:'ap-northeast-1'};//createstackmain.conststackM=newStack(mockApp,'testing-stackM',{env:envTokyo});constvpcPublic=newec2.Vpc(stackM,'defaultVpc',{natGateways:0,maxAzs:3,subnetConfiguration:[{cidrMask:26,name:'masterVPC2',subnetType:ec2.SubnetType.PUBLIC,}],});constglobaldbM=newGlobalAuroraRDSMaster(stackM,'globalAuroraRDSMaster',{instanceType:InstanceTypeEnum.R5_LARGE,vpc:vpcPublic,rdsPassword:'1qaz2wsx',});globaldbM.rdsCluster.connections.allowDefaultPortFrom(ec2.Peer.ipv4(`${process.env.MYIP}/32`))//createstackslaveinfraoryoucangiveyoursubnetgroup.conststackS=newStack(mockApp,'testing-stackS',{env:envSingapro});constvpcPublic2=newec2.Vpc(stackS,'defaultVpc2',{natGateways:0,maxAzs:3,subnetConfiguration:[{cidrMask:26,name:'secondVPC2',subnetType:ec2.SubnetType.PUBLIC,}],});constglobaldbS=newGlobalAuroraRDSSlaveInfra(stackS,'slaveregion',{vpc:vpcPublic2,subnetType:ec2.SubnetType.PUBLIC});//soweneedtowaitstackslavecreatedfirst.stackM.addDependency(stackS)newCfnOutput(stackM,'password',{value:globaldbM.rdsPassword});//addsecondregionclusterglobaldbM.addRegionalCluster(stackM,'addregionalrds',{region:'ap-southeast-1',dbSubnetGroupName:globaldbS.dbSubnetGroup.dbSubnetGroupName,});Sample for Postgresimport{GlobalAuroraRDSMaster,InstanceTypeEnum,GlobalAuroraRDSSlaveInfra}from'cdk-aurora-globaldatabase';import{App,Stack,CfnOutput}from'aws-cdk-lib';import*asec2from'aws-cdk-lib/aws-ec2';import*as_rdsfrom'aws-cdk-lib/aws-rds';constmockApp=newApp();constenvSingapro={account:process.env.CDK_DEFAULT_ACCOUNT,region:'ap-southeast-1'};constenvTokyo={account:process.env.CDK_DEFAULT_ACCOUNT,region:'ap-northeast-1'};conststackM=newStack(mockApp,'testing-stackM',{env:envTokyo});constvpcPublic=newec2.Vpc(stackM,'defaultVpc',{natGateways:0,maxAzs:3,subnetConfiguration:[{cidrMask:26,name:'masterVPC2',subnetType:ec2.SubnetType.PUBLIC,}],});//Noteifyouusepostgres,needtogivethesamevalueinengineVersionanddbClusterpPG's engine .constglobaldbM=newGlobalAuroraRDSMaster(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`))conststackS=newStack(mockApp,'testing-stackS',{env:envSingapro});constvpcPublic2=newec2.Vpc(stackS,'defaultVpc2',{natGateways:0,maxAzs:3,subnetConfiguration:[{cidrMask:26,name:'secondVPC2',subnetType:ec2.SubnetType.PUBLIC,}],});constglobaldbS=newGlobalAuroraRDSSlaveInfra(stackS,'slaveregion',{vpc:vpcPublic2,subnetType:ec2.SubnetType.PUBLIC,});stackM.addDependency(stackS)newCfnOutput(stackM,'password',{value:globaldbM.rdsPassword});//addsecondregionclusterglobaldbM.addRegionalCluster(stackM,'addregionalrds',{region:'ap-southeast-1',dbSubnetGroupName:globaldbS.dbSubnetGroup.dbSubnetGroupName,});To deploycdkdeployTo destroycdkdestroy:clap:  Supporters