From 807abb148961110b9046e23135516c1bf2c98e7b Mon Sep 17 00:00:00 2001 From: Edouard Demotes Date: Wed, 24 May 2023 23:58:55 -0400 Subject: [PATCH 1/2] feat(terraform-service-postgres): use fekide/volumerize:1.8.2-postgres to manage backups --- .../src/lib/configs/postgres.config.ts | 32 ++++++------------- .../src/lib/interfaces/backup.interface.ts | 26 ++++----------- 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/libs/terraform/service/postgres/src/lib/configs/postgres.config.ts b/libs/terraform/service/postgres/src/lib/configs/postgres.config.ts index 842ff144b..169d05d0d 100644 --- a/libs/terraform/service/postgres/src/lib/configs/postgres.config.ts +++ b/libs/terraform/service/postgres/src/lib/configs/postgres.config.ts @@ -1,9 +1,6 @@ -import { PostgresComponentDefaultConfig } from '../interfaces'; +import {PostgresComponentDefaultConfig} from '../interfaces'; -import { - Secret, - SERVICE_COMPONENT_DEFAULT_CONFIG, -} from '@trxn/terraform-service-ecs'; +import {Secret, SERVICE_COMPONENT_DEFAULT_CONFIG,} from '@trxn/terraform-service-ecs'; export const POSTGRES_COMPONENT_DEFAULT_CONFIG: PostgresComponentDefaultConfig = { @@ -19,28 +16,19 @@ export const POSTGRES_COMPONENT_DEFAULT_CONFIG: PostgresComponentDefaultConfig = }, enableBackups: false, backupsConfig: { - imageName: 'tractr/postgres-backup', - imageTag: 'v1.7', + imageName: 'fekide/volumerize', + imageTag: '1.8.2-postgres', environments: { VOLUMERIZE_SOURCE: '/source', VOLUMERIZE_TARGET: 'file:///backups', VOLUMERIZE_JOBBER_TIME: '0 0 */4 * * *', VOLUMERIZE_FULL_IF_OLDER_THAN: '3D', - JOB_NAME2: 'RemoveOldBackups', - JOB_COMMAND2: '/etc/volumerize/remove-older-than 1M --force', - JOB_TIME2: '0 0 2 * * *', - JOB_NOTIFY_ERR2: 'true', - JOB_NOTIFY_FAIL2: 'true', - JOB_NAME3: 'CleanupBackups', - JOB_COMMAND3: '/etc/volumerize/cleanup --force', - JOB_TIME3: '0 0 3 * * *', - JOB_NOTIFY_ERR3: 'true', - JOB_NOTIFY_FAIL3: 'true', - POSTGRES_DB: 'api', - POSTGRES_USER: Secret(), - POSTGRES_PASSWORD: Secret(), - POSTGRES_HOST: (service) => service.getServiceDomainName('postgres'), - POSTGRES_PORT: '5432', + REMOVE_OLDER_THAN: '30D', + VOLUMERIZE_POSTGRES_DATABASE: 'api', + VOLUMERIZE_POSTGRES_USERNAME: Secret('POSTGRES_USER'), + VOLUMERIZE_POSTGRES_PASSWORD: Secret('POSTGRES_PASSWORD'), + VOLUMERIZE_POSTGRES_HOST: (service) => service.getServiceDomainName('postgres'), + VOLUMERIZE_POSTGRES_PORT: '5432', }, }, }; diff --git a/libs/terraform/service/postgres/src/lib/interfaces/backup.interface.ts b/libs/terraform/service/postgres/src/lib/interfaces/backup.interface.ts index 08f10d78c..7fb0b32ee 100644 --- a/libs/terraform/service/postgres/src/lib/interfaces/backup.interface.ts +++ b/libs/terraform/service/postgres/src/lib/interfaces/backup.interface.ts @@ -1,8 +1,4 @@ -import { - ContainerInternalConfig, - ContainerPublicConfig, - EnvironmentOrSecretValue, -} from '@trxn/terraform-service-ecs'; +import {ContainerInternalConfig, ContainerPublicConfig, EnvironmentOrSecretValue,} from '@trxn/terraform-service-ecs'; export interface BackupContainerPublicConfig extends ContainerPublicConfig { environments: ContainerPublicConfig['environments'] & { @@ -10,23 +6,13 @@ export interface BackupContainerPublicConfig extends ContainerPublicConfig { VOLUMERIZE_TARGET: EnvironmentOrSecretValue; VOLUMERIZE_JOBBER_TIME: EnvironmentOrSecretValue; VOLUMERIZE_FULL_IF_OLDER_THAN: EnvironmentOrSecretValue; - JOB_NAME2?: EnvironmentOrSecretValue; - JOB_COMMAND2?: EnvironmentOrSecretValue; - JOB_TIME2?: EnvironmentOrSecretValue; - JOB_NOTIFY_ERR2?: EnvironmentOrSecretValue; - JOB_NOTIFY_FAIL2?: EnvironmentOrSecretValue; - JOB_NAME3?: EnvironmentOrSecretValue; - JOB_COMMAND3?: EnvironmentOrSecretValue; - JOB_TIME3?: EnvironmentOrSecretValue; - JOB_NOTIFY_ERR3?: EnvironmentOrSecretValue; - JOB_NOTIFY_FAIL3?: EnvironmentOrSecretValue; AWS_ACCESS_KEY_ID?: EnvironmentOrSecretValue; AWS_SECRET_ACCESS_KEY?: EnvironmentOrSecretValue; - POSTGRES_USER: EnvironmentOrSecretValue; - POSTGRES_PASSWORD: EnvironmentOrSecretValue; - POSTGRES_HOST: EnvironmentOrSecretValue; - POSTGRES_PORT: EnvironmentOrSecretValue; - POSTGRES_DB: EnvironmentOrSecretValue; + VOLUMERIZE_POSTGRES_USERNAME: EnvironmentOrSecretValue; + VOLUMERIZE_POSTGRES_PASSWORD: EnvironmentOrSecretValue; + VOLUMERIZE_POSTGRES_HOST: EnvironmentOrSecretValue; + VOLUMERIZE_POSTGRES_PORT: EnvironmentOrSecretValue; + VOLUMERIZE_POSTGRES_DATABASE: EnvironmentOrSecretValue; }; } export type BackupContainerConfig = ContainerInternalConfig & From da2cfafb910f2b8c290bf7cdc4813186fea7777c Mon Sep 17 00:00:00 2001 From: Edouard Demotes Date: Thu, 25 May 2023 00:06:03 -0400 Subject: [PATCH 2/2] chore(terraform-service-postgres): run format --- .../postgres/src/lib/configs/postgres.config.ts | 10 +++++++--- .../postgres/src/lib/interfaces/backup.interface.ts | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libs/terraform/service/postgres/src/lib/configs/postgres.config.ts b/libs/terraform/service/postgres/src/lib/configs/postgres.config.ts index 169d05d0d..f8dab3f89 100644 --- a/libs/terraform/service/postgres/src/lib/configs/postgres.config.ts +++ b/libs/terraform/service/postgres/src/lib/configs/postgres.config.ts @@ -1,6 +1,9 @@ -import {PostgresComponentDefaultConfig} from '../interfaces'; +import { PostgresComponentDefaultConfig } from '../interfaces'; -import {Secret, SERVICE_COMPONENT_DEFAULT_CONFIG,} from '@trxn/terraform-service-ecs'; +import { + Secret, + SERVICE_COMPONENT_DEFAULT_CONFIG, +} from '@trxn/terraform-service-ecs'; export const POSTGRES_COMPONENT_DEFAULT_CONFIG: PostgresComponentDefaultConfig = { @@ -27,7 +30,8 @@ export const POSTGRES_COMPONENT_DEFAULT_CONFIG: PostgresComponentDefaultConfig = VOLUMERIZE_POSTGRES_DATABASE: 'api', VOLUMERIZE_POSTGRES_USERNAME: Secret('POSTGRES_USER'), VOLUMERIZE_POSTGRES_PASSWORD: Secret('POSTGRES_PASSWORD'), - VOLUMERIZE_POSTGRES_HOST: (service) => service.getServiceDomainName('postgres'), + VOLUMERIZE_POSTGRES_HOST: (service) => + service.getServiceDomainName('postgres'), VOLUMERIZE_POSTGRES_PORT: '5432', }, }, diff --git a/libs/terraform/service/postgres/src/lib/interfaces/backup.interface.ts b/libs/terraform/service/postgres/src/lib/interfaces/backup.interface.ts index 7fb0b32ee..3c98d66f9 100644 --- a/libs/terraform/service/postgres/src/lib/interfaces/backup.interface.ts +++ b/libs/terraform/service/postgres/src/lib/interfaces/backup.interface.ts @@ -1,4 +1,8 @@ -import {ContainerInternalConfig, ContainerPublicConfig, EnvironmentOrSecretValue,} from '@trxn/terraform-service-ecs'; +import { + ContainerInternalConfig, + ContainerPublicConfig, + EnvironmentOrSecretValue, +} from '@trxn/terraform-service-ecs'; export interface BackupContainerPublicConfig extends ContainerPublicConfig { environments: ContainerPublicConfig['environments'] & {