in usecases/guest-webapp-sample/lib/blea-db-aurora-pg-sl-stack.ts [21:57]
constructor(scope: cdk.Construct, id: string, props: BLEADbAuroraPgSlStackProps) {
super(scope, id, props);
const serverlessCluster = new rds.ServerlessCluster(this, 'AuroraServerless', {
engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
parameterGroup: rds.ParameterGroup.fromParameterGroupName(this, 'ParameterGroup', 'default.aurora-postgresql10'),
vpc: props.myVpc,
vpcSubnets: props.vpcSubnets,
scaling: {
autoPause: cdk.Duration.minutes(10), // default is to pause after 5 minutes of idle time
minCapacity: rds.AuroraCapacityUnit.ACU_8, // default is 2 Aurora capacity units (ACUs)
maxCapacity: rds.AuroraCapacityUnit.ACU_32, // default is 16 Aurora capacity units (ACUs)
},
removalPolicy: cdk.RemovalPolicy.SNAPSHOT,
defaultDatabaseName: props.dbName,
storageEncryptionKey: props.appKey,
});
// ----------------------- Alarms for RDS -----------------------------
new cw.Metric({
metricName: 'CPUUtilization',
namespace: 'AWS/RDS',
dimensions: {
DBClusterIdentifier: serverlessCluster.clusterIdentifier,
},
period: cdk.Duration.minutes(1),
statistic: cw.Statistic.AVERAGE,
})
.createAlarm(this, 'CPUUtilization', {
evaluationPeriods: 3,
datapointsToAlarm: 2,
threshold: 90,
comparisonOperator: cw.ComparisonOperator.GREATER_THAN_THRESHOLD,
actionsEnabled: true,
})
.addAlarmAction(new cw_actions.SnsAction(props.alarmTopic));
}