This is the lowest-cost I like.
You can go for serverless_v2_min_capacity set to 0 (zero), for absolute minimum cost.
### Aurora Serverless v2 Cluster for PostgreSQL-v16
self.db = aws_rds.DatabaseCluster( self,
### ??? NOT-Serverless
### https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_rds/DatabaseCluster.html
id="AuroraV2-PGSQL",
default_database_name = default_database_name,
cluster_identifier = cluster_identifier,
engine = aws_rds.DatabaseClusterEngine.aurora_postgres(version=aws_rds.AuroraPostgresEngineVersion.VER_16_4),
enable_data_api = True, ### Default = False
auto_minor_version_upgrade = False,
writer=aws_rds.ClusterInstance.serverless_v2( id="AuroraWriter",
instance_identifier = f"{cluster_identifier}-writer",
#__ scale_with_writer = .. .. applies to READERs only
auto_minor_version_upgrade = False,
allow_major_version_upgrade = False,
publicly_accessible = False,
),
#__ readers = [IClusterInstance] ### A list of instances to create as cluster-reader-instances. Default: - no readers are created. The cluster will have a single writer/reader
serverless_v2_min_capacity = 1.0, # DEFAULT is 0.5 (lowest possible)
serverless_v2_max_capacity = serverless_aurorav2_max_capacity,
# instances = [0-9]+, ### !!!!! LEGACY DEPRECATED parameter !!! DEFAULT = 2 (Writer + 1-Reader)
### In V1-Aurora, we have to EXPLICITY provide the secret. Not so for V2!
### In V2-Aurora, Default-CDK-construct's behavior is to create a NEW username of 'admin' (or 'postgres' for PostgreSQL) and SecretsManager-generated password
# credentials=aws_rds.Credentials.from_secret(
# secret = self.rds_admin_dbo_secret,
# username = "admin_user"
# ),
# parameter_group=aws_rds.ParameterGroup.from_parameter_group_name(
# self,
# "ParameterGroup",
# f"default.aurora-postgresql{engine_ver_as_string}"
# ),
# network_type=aws_rds.NetworkType.IPV4,
# enable_local_write_forwarding = True, ## Whether read-replicas can forward write-operations to the writer-nstance. Only be enabled for MySQL 3.04+ or PostgreSQL 16.4+
backup=aws_rds.BackupProps(retention=Duration.days(30),
copy_tags_to_snapshot = True,
deletion_protection = True,
removal_policy = RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE,
vpc=vpc
subnet_group=self.rds_subnet_group,
security_groups=[self.rds_security_group],
# storage_type = aws_rds.DBClusterStorageType.AURORA_IOPT1, ### required for LIMITLESS mode
# storage_type = aws_rds.DBClusterStorageType.AURORA, ### Default: - DBClusterStorageType.AURORA_IOPT1
# instance_props=aws_rds.InstanceProps( !!!!!!!!!!!!!!!!!!! LEGACY DEPRECATED parameter !!!!!!!!!!!!!!!!!!!!
# # parameter_group = aws_rds.ParameterGroup.from_parameter_group_name( self, "ParamGrp", rds_paramgroup_name),
# vpc=self.vpc, ### WARNING: RuntimeError: Provide either vpc or instanceProps.vpc, but not both
# vpc_subnets = vpc_subnets, ### WARNING: RuntimeError: Provide either vpc or instanceProps.vpc, but not both
# security_groups=[self.rds_security_group], ### WARNING: RuntimeError: Provide either vpc or instanceProps.vpc, but not both
# allow_major_version_upgrade = False,
# publicly_accessible = False,
# delete_automated_backups = False,
# instance_type=aws_ec2.InstanceType.of( !!!!!!! LEGACY DEPRECATED parameter !!!!!!!!
# aws_ec2.InstanceClass.R6GD,
# aws_ec2.InstanceSize.XLARGE4,
# ),
# ),
# cluster_scailability_type=aws_rds.ClusterScailabilityType.STANDARD,
# enable_performance_insights=True, ### RuntimeError: Performance Insights must be enabled for Aurora Limitless Database.
# performance_insight_retention=aws_rds.PerformanceInsightRetention.MONTHS_1,
# enable_cluster_level_enhanced_monitoring=True, ### RuntimeError: Cluster level enhanced monitoring must be set for Aurora Limitless Database. Please set 'monitoringInterval' and enable 'enableClusterLevelEnhancedMonitoring'.
# monitoring_interval=Duration.seconds(60), ### Max 1 minute. RuntimeError: Cluster level enhanced monitoring must be set for Aurora Limitless Database. Please set 'monitoringInterval' and enable 'enableClusterLevelEnhancedMonitoring'.
### Default: NO enhanced monitoring
# monitoring_role -- Default: Role is Automatically created -- will be used to manage DB instances monitoring
# cloudwatch_logs_exports = [str] ### list of log-types that need to be enabled, for exporting to CW-Logs. Default: - --NO-- log exports
# cloudwatch_logs_retention = RetentionDays() ### Default: - logs --NEVER-- expire. # of days log-events are kept in CW-Logs. To remove the retention policy, set the value to Infinity.
# backtrack_window = .. MySql only.
# s3_export_buckets = .. MySql only.
# s3_import_buckets = .. MySql only.
)