import * as cdk from "aws-cdk-lib"; import type * as cloudwatch from "aws-cdk-lib/aws-cloudwatch"; import * as ec2 from "aws-cdk-lib/aws-ec2"; import * as rds from "aws-cdk-lib/aws-rds"; import type * as sm from "aws-cdk-lib/aws-secretsmanager"; import * as constructs from "constructs"; /** * Configure database alarms. * * Alarms are enabled by default (when you supply an `alarmAction` and * `warningAction`). To explicitly disable automatic alarms use * `{ enabled: false }`. */ export type DatabaseAlarmsConfig = { enabled: false; } | { /** * When alarms are enabled, both actions are required. */ alarmAction: cloudwatch.IAlarmAction; warningAction: cloudwatch.IAlarmAction; /** * CPU credits alarm config */ cpuCreditsAlarm?: { /** * @default true if instance type is burstable */ enabled?: boolean; /** Whether to attach OK actions for this alarm. @default true */ enableOkAlarm?: boolean; action?: cloudwatch.IAlarmAction; /** @default 10% of maximum earned credits for instance type */ threshold?: number; appendToAlarmDescription?: string; }; /** * Storage space alarm overrides */ storageSpaceAlarms?: { /** * Set to `false` to disable all storage space alarms (both low and critically low). * Individual alarms can still be disabled even when this is true. * @default true */ enabled?: boolean; lowStorageSpaceAlarm?: { /** * Set to `false` to disable the low storage space alarm. * @default true */ enabled?: boolean; action?: cloudwatch.IAlarmAction; /** Whether to attach OK actions for this alarm. @default true */ enableOkAlarm?: boolean; /** @default 25% of allocated storage */ threshold?: cdk.Size; }; criticallyLowStorageSpaceAlarm?: { /** * Set to `false` to disable the critically low storage space alarm. * @default true */ enabled?: boolean; action?: cloudwatch.IAlarmAction; /** Whether to attach OK actions for this alarm. @default true */ enableOkAlarm?: boolean; /** @default 5% of allocated storage */ threshold?: cdk.Size; }; appendToAlarmDescription?: string; }; /** * CPU utilization alarm overrides. */ cpuUtilizationAlarm?: { enabled?: boolean; /** Whether to attach OK actions for this alarm. @default true */ enableOkAlarm?: boolean; action?: cloudwatch.IAlarmAction; /** @default 80 */ threshold?: number; /** @default 5 */ evaluationPeriods?: number; /** @default 2 minutes */ period?: cdk.Duration; appendToAlarmDescription?: string; }; }; export interface DatabaseProps extends cdk.StackProps { vpc: ec2.IVpc; engine: rds.IInstanceEngine; /** * @default master */ masterUsername?: string; /** * @default app */ databaseName?: string; /** * @default 25 */ allocatedStorageGb?: number; instanceType: ec2.InstanceType; instanceIdentifier: string; /** * @default true */ isMultiAz?: boolean; /** * Must not be removed once it has been set, as changing this * results in a new DB instance being created. * * Also, remember to give database a new name when changing this prop, or else * the new instance name will crash with the existing instance. */ snapshotIdentifier?: string; /** * @default false */ usePublicSubnets?: boolean; /** * Weekly maintenance window in UTC, format `ddd:hh:mm-ddd:hh:mm`. * Minimum 30 minutes; must not overlap `preferredBackupWindow`. * * @default AWS-assigned * @example "sun:03:00-sun:04:00" */ preferredMaintenanceWindow?: string; /** * Daily backup window in UTC, format `hh:mm-hh:mm`. * Minimum 30 minutes; must not overlap `preferredMaintenanceWindow`. * * @default AWS-assigned * @example "01:00-02:00" */ preferredBackupWindow?: string; /** * Whether AWS automatically applies minor engine version upgrades * during the maintenance window. * * @default AWS default (true) */ autoMinorVersionUpgrade?: boolean; /** * Escape hatch for RDS option combinations the construct doesn't expose * directly. Overrides any value set via the typed props above. */ overrideDbOptions?: Partial; /** * Configure database alarms. * * This property is required and must be one of two shapes: * - `{ enabled: false }` to explicitly disable automatic alarms * - `{ alarmAction, warningAction }` to enable alarms and provide both channels * * Default: enabled. */ alarms: DatabaseAlarmsConfig; } export declare class Database extends constructs.Construct { readonly secret: sm.ISecret; readonly connections: ec2.Connections; readonly databaseInstance: rds.IDatabaseInstance; readonly instanceType: ec2.InstanceType; readonly allocatedStorage: cdk.Size; constructor(scope: constructs.Construct, id: string, props: DatabaseProps); allowConnectionFrom(source: ec2.ISecurityGroup): void; }