Skip to content

Commit 8943259

Browse files
committed
feat(database): enable Data API and connection logging (#122)
Why: The Aurora Serverless v2 cluster lacks operational tooling for debugging and diagnostics. Without Data API, operators must use SSH tunneling via Bastion Host to run ad-hoc queries. Without connection logs, diagnosing unexpected auto-pause resumes or connection pool exhaustion requires guesswork. What: - Enable RDS Data API for direct SQL execution from AWS CLI/Console - Add log_connections and log_disconnections parameters - Export PostgreSQL logs to CloudWatch Logs with 1-week retention
1 parent 764a4fa commit 8943259

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cdk/lib/constructs/database.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CfnOutput, Stack, Token } from 'aws-cdk-lib';
22
import * as ec2 from 'aws-cdk-lib/aws-ec2';
3+
import * as logs from 'aws-cdk-lib/aws-logs';
34
import * as rds from 'aws-cdk-lib/aws-rds';
45
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
56
import { Construct } from 'constructs';
@@ -34,11 +35,16 @@ export class Database extends Construct implements ec2.IConnectable {
3435
credentials: rds.Credentials.fromUsername(engine.defaultUsername ?? 'admin', {
3536
excludeCharacters: ' %+~`#$&*()|[]{}:;<>?!\'/@"\\,=^',
3637
}),
38+
enableDataApi: true,
39+
cloudwatchLogsExports: ['postgresql'],
40+
cloudwatchLogsRetention: logs.RetentionDays.ONE_WEEK,
3741
parameterGroup: new rds.ParameterGroup(this, 'ParameterGroup', {
3842
engine,
3943
parameters: {
4044
// Close idle connection after 60 seconds for Aurora auto-pause
4145
idle_session_timeout: '60000',
46+
log_connections: '1',
47+
log_disconnections: '1',
4248
},
4349
}),
4450
});

0 commit comments

Comments
 (0)