Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

macrodb replica (#2251)

Will Hutchinsonf696e1fac792
diff --git a/infra/stacks/macrodb/Pulumi.dev.yaml b/infra/stacks/macrodb/Pulumi.dev.yaml
index 10fed62049..921f8fb9e8 100644
--- a/infra/stacks/macrodb/Pulumi.dev.yaml
+++ b/infra/stacks/macrodb/Pulumi.dev.yaml
@@ -14,3 +14,5 @@ config:
macrodb:subnet_group_name: macro-db-dev-stack-macrodbinstancesubnetgroup483984b1-io15kk1yffvr
macrodb:security_group_ids: sg-0c947d88145e1141b
macrodb:backup_retention_days: 1
+ macrodb:read_replica_enabled: true
+ macrodb:read_replica_instance_size: db.t4g.micro
diff --git a/infra/stacks/macrodb/Pulumi.prod.yaml b/infra/stacks/macrodb/Pulumi.prod.yaml
index 5c1562f3f8..b17a0e2ec4 100644
--- a/infra/stacks/macrodb/Pulumi.prod.yaml
+++ b/infra/stacks/macrodb/Pulumi.prod.yaml
@@ -16,3 +16,5 @@ config:
macrodb:subnet_group_name: macro-db-prod-stack-macrodbinstancesubnetgroup483984b1-ny9ca5kliq6z
macrodb:security_group_ids: sg-0997207417c39f5b3
macrodb:backup_retention_days: 6
+ macrodb:read_replica_enabled: true
+ macrodb:read_replica_instance_size: db.t4g.small
diff --git a/infra/stacks/macrodb/index.ts b/infra/stacks/macrodb/index.ts
index ef78cac6e1..1430406c64 100644
--- a/infra/stacks/macrodb/index.ts
+++ b/infra/stacks/macrodb/index.ts
@@ -82,3 +82,48 @@ const database = new aws.rds.Instance(
);
export const endpoint = database.endpoint;
+
+// ---- Read Replica ----
+
+const enableReadReplica = config.getBoolean('read_replica_enabled') ?? false;
+
+const readReplica = enableReadReplica
+ ? new aws.rds.Instance(
+ 'read-replica',
+ {
+ applyImmediately: stack !== 'prod',
+ identifier: `macro-db-${stack}-read-replica`,
+ replicateSourceDb: database.identifier,
+ instanceClass: config.require('read_replica_instance_size'),
+ storageType: config.require('storage_type'),
+ iops: config.getNumber('storage_iops'),
+ storageThroughput: config.getNumber('storage_throughput'),
+ caCertIdentifier: config.require('ca_cert_identifier'),
+ kmsKeyId: config.require('kms_key_id'),
+ storageEncrypted: true,
+ performanceInsightsEnabled: true,
+ performanceInsightsRetentionPeriod: config.requireNumber(
+ 'performance_insights_retention_days'
+ ),
+ performanceInsightsKmsKeyId: config.require(
+ 'performance_insights_kms_key_id'
+ ),
+ publiclyAccessible: true,
+ vpcSecurityGroupIds: [
+ ...config.require('security_group_ids').split(','),
+ ],
+ parameterGroupName: pulumi.interpolate`${parameterGroup.name}`,
+ enabledCloudwatchLogsExports:
+ stack === 'prod' ? ['postgresql', 'upgrade'] : undefined,
+ skipFinalSnapshot: true,
+ deletionProtection: stack === 'prod',
+ tags: {
+ ...tags,
+ role: 'read-replica',
+ },
+ },
+ { dependsOn: [database] }
+ )
+ : undefined;
+
+export const readReplicaEndpoint = readReplica?.endpoint;