Created
July 17, 2025 15:48
-
-
Save jac18281828/20fa7dcb6dcec23425b0e16848f76fc4 to your computer and use it in GitHub Desktop.
Create Aurora Postgress Serverless Instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Define Aurora Serverless v2 PostgreSQL cluster | |
| self.aurora_cluster = rds.DatabaseCluster( | |
| self, | |
| "AuroraServerlessCluster", | |
| engine=rds.DatabaseClusterEngine.aurora_postgres(version=rds.AuroraPostgresEngineVersion.VER_16_6), | |
| writer=rds.ClusterInstance.provisioned( | |
| "writer", instance_type=ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.LARGE) | |
| ), | |
| serverless_v2_min_capacity=0, # allow auto pause | |
| serverless_v2_max_capacity=8, | |
| readers=[ | |
| # will be put in promotion tier 1 and will scale with the writer | |
| rds.ClusterInstance.serverless_v2("reader1", scale_with_writer=True), | |
| # will be put in promotion tier 2 and will not scale with the writer | |
| rds.ClusterInstance.serverless_v2("reader2"), | |
| ], | |
| vpc=self.vpc, | |
| vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS), | |
| credentials=rds.Credentials.from_secret(self.db_credentials_secret), | |
| storage_encryption_key=kms.Key.from_key_arn(self, "ServerlessKMSKeyArn", kms_key.key_arn), | |
| default_database_name=self.DATABASE_NAME, | |
| removal_policy=RemovalPolicy.DESTROY, # Cleanup for test environments | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment