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.

feat(notification_service): migrate to doppler (#4099)

Will Hutchinson6217915f1774
diff --git a/infra/stacks/notification-service/Pulumi.dev.yaml b/infra/stacks/notification-service/Pulumi.dev.yaml
index 0791047f93..dcdb6f8af4 100644
--- a/infra/stacks/notification-service/Pulumi.dev.yaml
+++ b/infra/stacks/notification-service/Pulumi.dev.yaml
@@ -11,6 +11,4 @@ config:
notification-service:apns_private_key:
secure: AAABABgzjPffyo4Dh/SryGRapUIuJ2WXRrv2O879SfFOTC6sAu2uIKnCtzDyZSgCJ1Or8opS7RBV648ysgMygoIPZnwGn0lkSxbz8L4GiDk0Wd9MHedXJpi7oDdcR7AHdf+GBievPO2Afi6Ta7LVmb4BM5ig8rMDG9B5U3FofsgQNDvVXu5r8dsRZjKKGqN76mXQ+eSCxlJLWHlRluy28Ns7Aay8AzJLRnD3h8+qrF9mc49lr45f003aOu0/YojWn6QlAcK0tb0O3B+PsM+LDrk99B6oAzOZpPkT1qfFfOy0Wk76jlvsm0zOIA==
notification-service:fcm_secret_key: fcm-credential-dev
- notification-service:macro_cache_secret_key: macro-cache-dev
notification-service:authentication_service_internal_api_key: authentication-service-internal-api-key-dev
- notification-service:macro_db_secret_key: macro-db-dev
diff --git a/infra/stacks/notification-service/Pulumi.prod.yaml b/infra/stacks/notification-service/Pulumi.prod.yaml
index e242017e7f..809c1efa52 100644
--- a/infra/stacks/notification-service/Pulumi.prod.yaml
+++ b/infra/stacks/notification-service/Pulumi.prod.yaml
@@ -11,6 +11,4 @@ config:
notification-service:apns_private_key:
secure: AAABAKWe7JBlRN/BDxH4YFtm06Jry3kcv3jMudROKehPGxqEOEFsukTwQphhJm/+2dk3oFEHvqTDQEF4hOZmdNsa8Lz3f5jP+XgOEgcT2MBkH+QnvOwdYc97B72FRKPi6cmHLPz/9d4S05Jku0XCDhlGgMwYTc7K2vAzdPhCeC+KqAaKzcQmbm9hp5U4CEgo9FY9/GFZbgdHkdeLNC/U2rR8GSNmQoDQoCZEsvj9Btph5XURI6griy4Ou2iypKRRhcw+/jOLxVSOeRoVmKG3FGWsqsmlGC0AmvIKeD3bgrlFnMFUd1/EuP4tDsvhmi7/C7aeRcs+ryXWKFdIzWmnqyfPEu/otczlaMaTU0kiere3b1YsIO4sv8C/1i81FTvy/w==
notification-service:fcm_secret_key: fcm-credential-prod
- notification-service:macro_cache_secret_key: macro-cache-prod
notification-service:authentication_service_internal_api_key: authentication-service-internal-api-key-prod
- notification-service:macro_db_secret_key: macro-db-prod
diff --git a/infra/stacks/notification-service/index.ts b/infra/stacks/notification-service/index.ts
index 17e19ac336..5790be995a 100644
--- a/infra/stacks/notification-service/index.ts
+++ b/infra/stacks/notification-service/index.ts
@@ -1,13 +1,7 @@
import * as aws from '@pulumi/aws';
import * as pulumi from '@pulumi/pulumi';
import { Queue } from '../../packages/resources';
-import {
- config,
- getMacroApiToken,
- getServiceUrl,
- ServiceUrl,
- stack,
-} from '../../packages/shared';
+import { config, getMacroApiToken, stack } from '../../packages/shared';
import { get_coparse_api_vpc } from '../../packages/vpc';
import { PushNotificationEventHandler } from './push';
import { NotificationService } from './service';
@@ -28,15 +22,6 @@ const internalApiKeyArn: pulumi.Output<string> = aws.secretsmanager
.getSecretVersionOutput({ secretId: INTERNAL_API_SECRET_KEY })
.apply((secret) => secret.arn);
-const fusionauthClientIdSecretKey = config.require(`fusionauth_client_id`);
-const AUDIENCE = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: fusionauthClientIdSecretKey,
- })
- .apply((secret) => secret.secretString);
-
-const ISSUER = config.require(`fusionauth_issuer`);
-
const appleTeamId = config.require(`apple_team_id`);
const APPLE_TEAM_ID = aws.secretsmanager
.getSecretVersionOutput({ secretId: appleTeamId })
@@ -63,12 +48,6 @@ const fcmCredentials: pulumi.Output<string> = aws.secretsmanager
.getSecretVersionOutput({ secretId: FCM_SECRET_KEY })
.apply((secret) => secret.secretString);
-const MACRO_CACHE = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require(`macro_cache_secret_key`),
- })
- .apply((secret) => secret.secretString);
-
const AUTHENTICATION_SERVICE_INTERNAL_API_KEY = config.require(
`authentication_service_internal_api_key`
);
@@ -94,23 +73,6 @@ const cloudStorageClusterName: pulumi.Output<string> = cloudStorageStack
.getOutput('cloudStorageClusterName')
.apply((arn) => arn as string);
-const connectionGatewayStack = new pulumi.StackReference(
- 'connection-gateway-stack',
- {
- name: `macro-inc/connection-gateway/${stack}`,
- }
-);
-
-const connectionGatewayRedisUrl: pulumi.Output<string> = connectionGatewayStack
- .getOutput('connectionGatewayRedisUrl')
- .apply((url) => url as string);
-
-const DATABASE_URL = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require(`macro_db_secret_key`),
- })
- .apply((secret) => secret.secretString);
-
const notificationQueue = new Queue('notification', {
tags,
});
@@ -174,7 +136,6 @@ const notificationFcmPlatform = new aws.sns.PlatformApplication(
);
const notificationQueueArn = notificationQueue.queue.arn;
-const notificationQueueName = notificationQueue.queue.name;
export const notificationIngressQueueArn = notificationIngressQueue.queue.arn;
export const notificationIngressQueueName = notificationIngressQueue.queue.name;
export const notificationSnsPlatformArns = [
@@ -209,106 +170,6 @@ const notificationService = new NotificationService('notification-service', {
healthCheckPath: '/health',
platform: { family: 'linux', architecture: 'amd64' },
containerEnvVars: [
- {
- name: 'RUST_LOG',
- value: `error,notification_service=${stack === 'prod' ? 'debug' : 'trace'},notification=${stack === 'prod' ? 'debug' : 'trace'},notification_db_client=${stack === 'prod' ? 'info' : 'debug'},tower_http=info`,
- },
- {
- name: 'ENVIRONMENT',
- value: stack,
- },
- {
- name: 'DATABASE_URL',
- value: pulumi.interpolate`${DATABASE_URL}`,
- },
- {
- name: 'JWT_SECRET_KEY',
- value: pulumi.interpolate`${JWT_SECRET_KEY}`,
- },
- {
- name: 'AUDIENCE',
- value: pulumi.interpolate`${AUDIENCE}`,
- },
- {
- name: 'ISSUER',
- value: pulumi.interpolate`${ISSUER}`,
- },
- {
- name: 'INTERNAL_API_SECRET_KEY',
- value: pulumi.interpolate`${INTERNAL_API_SECRET_KEY}`,
- },
- {
- name: 'NOTIFICATION_QUEUE',
- value: pulumi.interpolate`${notificationQueueName}`,
- },
- {
- name: 'NOTIFICATION_INGRESS_QUEUE',
- value: pulumi.interpolate`${notificationIngressQueueName}`,
- },
- {
- name: 'PUSH_NOTIFICATION_EVENT_HANDLER_QUEUE',
- value: pulumi.interpolate`${pushNotificationEventHandlerQueueName}`,
- },
- {
- name: ServiceUrl.DOCUMENT_STORAGE_SERVICE_URL,
- value: getServiceUrl(ServiceUrl.DOCUMENT_STORAGE_SERVICE_URL),
- },
- {
- name: ServiceUrl.DOCUMENT_COGNITION_SERVICE_URL,
- value: getServiceUrl(ServiceUrl.DOCUMENT_COGNITION_SERVICE_URL),
- },
- {
- name: ServiceUrl.CONNECTION_GATEWAY_URL,
- value: getServiceUrl(ServiceUrl.CONNECTION_GATEWAY_URL),
- },
- {
- name: 'SNS_APNS_PLATFORM_ARN',
- value: pulumi.interpolate`${notificationApnsPlatform.arn}`,
- },
- {
- name: 'SNS_FCM_PLATFORM_ARN',
- value: pulumi.interpolate`${notificationFcmPlatform.arn}`,
- },
- {
- name: 'SNS_APNS_VOIP_PLATFORM_ARN',
- value: pulumi.interpolate`${notificationApnsVoipPlatform.arn}`,
- },
- {
- name: 'SENDER_BASE_ADDRESS',
- value: 'notification.macro.com',
- },
- {
- name: 'APPLE_BUNDLE_ID',
- value: APPLE_BUNDLE_ID,
- },
- {
- name: 'REDIS_URI',
- value: pulumi.interpolate`redis://${MACRO_CACHE}`,
- },
- {
- name: 'LAST_ONLINE_REDIS_URI',
- value: pulumi.interpolate`redis://${connectionGatewayRedisUrl}`,
- },
- {
- name: 'MACRO_API_TOKEN_ISSUER',
- value: pulumi.interpolate`${MACRO_API_TOKENS.macroApiTokenIssuer}`,
- },
- {
- name: 'MACRO_API_TOKEN_PUBLIC_KEY',
- value: pulumi.interpolate`${MACRO_API_TOKENS.macroApiTokenPublicKey}`,
- },
- {
- name: ServiceUrl.AUTHENTICATION_SERVICE_URL,
- value: getServiceUrl(ServiceUrl.AUTHENTICATION_SERVICE_URL),
- },
- {
- name: 'AUTHENTICATION_SERVICE_SECRET_KEY',
- value: pulumi.interpolate`${AUTHENTICATION_SERVICE_INTERNAL_API_KEY}`,
- },
- {
- name: 'URL_SIGNING_HMAC',
- value: UNSUBSCRIBE_HMAC_SECRET_KEY,
- },
// OpenTelemetry / Datadog tracing configuration
{
name: 'DD_SERVICE',
diff --git a/infra/stacks/notification-service/service.ts b/infra/stacks/notification-service/service.ts
index f6f025a9ae..f098a09ac8 100644
--- a/infra/stacks/notification-service/service.ts
+++ b/infra/stacks/notification-service/service.ts
@@ -13,10 +13,11 @@ import { EcrImage } from '../../packages/service';
import {
BASE_DOMAIN,
CLOUD_TRAIL_SNS_TOPIC_ARN,
+ DopplerEcsEnvironment,
stack,
} from '../../packages/shared';
-const BASE_NAME = 'notification-service';
+const BASE_NAME = pulumi.getProject();
const BASE_PATH = '../../../rust/cloud-storage';
export const SERVICE_DOMAIN_NAME = `notifications${
@@ -240,6 +241,12 @@ export class NotificationService extends pulumi.ComponentResource {
this.lb = lb;
this.listener = listener;
+ const dopplerEcsEnvironment = new DopplerEcsEnvironment(
+ BASE_NAME,
+ { tags: this.tags },
+ { parent: this }
+ );
+
// service
const service = new awsx.ecs.FargateService(
`${BASE_NAME}`,
@@ -259,6 +266,9 @@ export class NotificationService extends pulumi.ComponentResource {
taskRole: {
roleArn: this.role.arn,
},
+ executionRole: {
+ roleArn: dopplerEcsEnvironment.executionRole.arn,
+ },
containers: {
log_router: fargateLogRouterSidecarContainer,
datadog_agent: datadogAgentContainer,
@@ -275,6 +285,7 @@ export class NotificationService extends pulumi.ComponentResource {
value: this.domain,
},
],
+ secrets: [...dopplerEcsEnvironment.containerSecrets],
logConfiguration: {
logDriver: 'awsfirelens',
options: {