From 7095e22567a162ccf915e274036638dd6de3134f Mon Sep 17 00:00:00 2001 From: nutrina Date: Wed, 7 Feb 2024 22:04:15 +0200 Subject: [PATCH] 2139 analytics read replica (#518) * feat[api]: remove field provider_clone in CeramicCache * feat[infra]: adding read replica for analytics --- infra/prod/index.ts | 38 ++++++++++++++++++++++++++++++++++++++ infra/staging/index.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/infra/prod/index.ts b/infra/prod/index.ts index 5c0776997..e816a94bc 100644 --- a/infra/prod/index.ts +++ b/infra/prod/index.ts @@ -193,6 +193,41 @@ const readreplica0 = new aws.rds.Instance( { protect: true } ); +const analyticsDbParameterGroup = new aws.rds.ParameterGroup('analytics-parameter-group', { + + family: 'postgres13', // The family should match the DB engine version + parameters: [ // A list of DB parameters you want to set + { + name: 'max_standby_archive_delay', + value: '900', + }, + { + name: 'max_standby_streaming_delay', + value: '900', + }, + ], +}); + +const readreplica1 = new aws.rds.Instance( + "scorer-db-read-analytics", + { + allocatedStorage: 130, + maxAllocatedStorage: 500, + instanceClass: "db.t3.xlarge", + skipFinalSnapshot: true, + vpcSecurityGroupIds: [db_secgrp.id], + deletionProtection: true, + // backupRetentionPeriod: 5, - this is not supported for read replicas running PostgreSQL versions lower than 14 + replicateSourceDb: postgresql.id, + performanceInsightsEnabled: true, + tags: { + name: "scorer-db-read-analytics", + }, + parameterGroupName: analyticsDbParameterGroup.name, + }, + { protect: true } +); + ////////////////////////////////////////////////////////////// // Setup RDS PROXY ////////////////////////////////////////////////////////////// @@ -292,6 +327,9 @@ export const rdsConnectionUrl = pulumi.secret( export const readreplica0ConnectionUrl = pulumi.secret( pulumi.interpolate`psql://${dbUsername}:${dbPassword}@${readreplica0.endpoint}/${dbName}` ); +export const readreplica1ConnectionUrl = pulumi.secret( + pulumi.interpolate`psql://${dbUsername}:${dbPassword}@${readreplica1.endpoint}/${dbName}` +); export const rdsId = postgresql.id; diff --git a/infra/staging/index.ts b/infra/staging/index.ts index d61158ca9..b174dc737 100644 --- a/infra/staging/index.ts +++ b/infra/staging/index.ts @@ -164,6 +164,45 @@ const postgresql = new aws.rds.Instance( { protect: true } ); +const analyticsDbParameterGroup = new aws.rds.ParameterGroup( + "analytics-parameter-group", + { + family: "postgres13", // The family should match the DB engine version + parameters: [ + // A list of DB parameters you want to set + { + name: "max_standby_archive_delay", + value: "900", + }, + { + name: "max_standby_streaming_delay", + value: "900", + }, + ], + } +); + +const readreplica1 = new aws.rds.Instance( + "scorer-db-read-analytics", + { + allocatedStorage: 130, + maxAllocatedStorage: 500, + engine: "postgres", + instanceClass: "db.t3.micro", + skipFinalSnapshot: true, + vpcSecurityGroupIds: [db_secgrp.id], + deletionProtection: true, + // backupRetentionPeriod: 5, - this is not supported for read replicas running PostgreSQL versions lower than 14 + replicateSourceDb: postgresql.id, + performanceInsightsEnabled: true, + tags: { + name: "scorer-db-read-analytics", + }, + parameterGroupName: analyticsDbParameterGroup.name, + }, + { protect: false } +); + ////////////////////////////////////////////////////////////// // Setup RDS PROXY ////////////////////////////////////////////////////////////// @@ -255,6 +294,7 @@ const scorerDefaultProxyTarget = new aws.rds.ProxyTarget( export const scorerDbProxyEndpoint = scorerDbProxy.endpoint; export const rdsEndpoint = postgresql.endpoint; +export const rdsAnalyticsEndpoint = postgresql.endpoint; export const rdsArn = postgresql.arn; export const rdsConnectionUrl = pulumi.secret( pulumi.interpolate`psql://${dbUsername}:${dbPassword}@${scorerDbProxyEndpoint}/${dbName}`