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(doppler): agent schedule service (#4297)

Will Hutchinson1d7b11214457
diff --git a/infra/stacks/agent-schedule-service/index.ts b/infra/stacks/agent-schedule-service/index.ts
index 74eda4e537..871f6a95a3 100644
--- a/infra/stacks/agent-schedule-service/index.ts
+++ b/infra/stacks/agent-schedule-service/index.ts
@@ -5,8 +5,6 @@ import {
getAiToolsInfra,
getMacroApiToken,
getMacroNotify,
- getServiceUrl,
- ServiceUrl,
stack,
} from '../../packages/shared';
import { get_coparse_api_vpc } from '../../packages/vpc';
@@ -22,46 +20,13 @@ const tags = {
// ── Secrets ──────────────────────────────────────────────────────────────────
-const DATABASE_URL = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require('macro_db_secret_key'),
- })
- .apply((secret) => secret.secretString);
-
const JWT_SECRET_KEY = config.require('jwt_secret_key');
const jwtSecretKeyArn = aws.secretsmanager
.getSecretVersionOutput({ secretId: JWT_SECRET_KEY })
.apply((secret) => secret.arn);
-const FUSIONAUTH_CLIENT_ID = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require('fusionauth_client_id'),
- })
- .apply((secret) => secret.secretString);
-
-const FUSIONAUTH_ISSUER = config.require('fusionauth_issuer');
-
-const OPEN_ROUTER_API_KEY = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require('open-router-api-key'),
- })
- .apply((secret) => secret.secretString);
-
-const XAI_API_KEY = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require('xai-api-key'),
- })
- .apply((secret) => secret.secretString);
-
-const PERPLEXITY_API_KEY = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require('perplexity-api-key'),
- })
- .apply((secret) => secret.secretString);
-
const MACRO_API_TOKENS = getMacroApiToken();
-const { notificationIngressQueueArn, notificationIngressQueueName } =
- getMacroNotify();
+const { notificationIngressQueueArn } = getMacroNotify();
// ── AI tools infra ───────────────────────────────────────────────────────────
@@ -102,68 +67,10 @@ const service = new AgentScheduleService(`agent-schedule-service-${stack}`, {
queueArns: [notificationIngressQueueArn, ...aiTools.queueArns],
bucketArns: [...aiTools.bucketArns],
containerEnvVars: [
- ...aiTools.envVars,
- // Core
- {
- name: 'DATABASE_URL',
- value: pulumi.interpolate`${DATABASE_URL}`,
- },
- {
- name: 'PORT',
- value: '8080',
- },
{
name: 'ENVIRONMENT',
value: stack,
},
- {
- name: 'RUST_LOG',
- value: 'scheduled_action=info,ai=info,ai_tools=info,tower_http=info',
- },
- // Auth
- {
- name: 'JWT_SECRET_KEY',
- value: pulumi.interpolate`${JWT_SECRET_KEY}`,
- },
- {
- name: 'AUDIENCE',
- value: pulumi.interpolate`${FUSIONAUTH_CLIENT_ID}`,
- },
- {
- name: 'ISSUER',
- value: pulumi.interpolate`${FUSIONAUTH_ISSUER}`,
- },
- {
- 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}`,
- },
- // Queues
- {
- name: 'NOTIFICATION_QUEUE',
- value: pulumi.interpolate`${notificationIngressQueueName}`,
- },
- // Service URLs not covered by ai_tools
- {
- name: ServiceUrl.CONNECTION_GATEWAY_URL,
- value: getServiceUrl(ServiceUrl.CONNECTION_GATEWAY_URL),
- },
- // AI model API keys
- {
- name: 'OPEN_ROUTER_API_KEY',
- value: pulumi.interpolate`${OPEN_ROUTER_API_KEY}`,
- },
- {
- name: 'XAI_API_KEY',
- value: pulumi.interpolate`${XAI_API_KEY}`,
- },
- {
- name: 'PERPLEXITY_API_KEY',
- value: pulumi.interpolate`${PERPLEXITY_API_KEY}`,
- },
// Datadog
{
name: 'DD_SERVICE',
diff --git a/infra/stacks/agent-schedule-service/service.ts b/infra/stacks/agent-schedule-service/service.ts
index c5016179cd..6914a5405e 100644
--- a/infra/stacks/agent-schedule-service/service.ts
+++ b/infra/stacks/agent-schedule-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 = 'agent-schedule-service';
+const BASE_NAME = pulumi.getProject();
const BASE_PATH = '../../../rust/cloud-storage';
export const SERVICE_DOMAIN_NAME = `agent-schedule${
@@ -214,6 +215,12 @@ export class AgentScheduleService extends pulumi.ComponentResource {
this.lb = lb;
this.listener = listener;
+ const dopplerEcsEnvironment = new DopplerEcsEnvironment(
+ BASE_NAME,
+ { tags: this.tags },
+ { parent: this }
+ );
+
this.service = new awsx.ecs.FargateService(
`${BASE_NAME}`,
{
@@ -232,6 +239,9 @@ export class AgentScheduleService extends pulumi.ComponentResource {
taskRole: {
roleArn: this.role.arn,
},
+ executionRole: {
+ roleArn: dopplerEcsEnvironment.executionRole.arn,
+ },
containers: {
log_router: fargateLogRouterSidecarContainer,
datadog_agent: datadogAgentContainer,
@@ -248,6 +258,7 @@ export class AgentScheduleService extends pulumi.ComponentResource {
value: this.domain,
},
],
+ secrets: [...dopplerEcsEnvironment.containerSecrets],
logConfiguration: {
logDriver: 'awsfirelens',
options: {
diff --git a/infra/stacks/doppler-projects/index.ts b/infra/stacks/doppler-projects/index.ts
index eef58df604..594b76d7d1 100644
--- a/infra/stacks/doppler-projects/index.ts
+++ b/infra/stacks/doppler-projects/index.ts
@@ -11,6 +11,7 @@ const SERVICE_NAMES = [
'static-file-service',
'image-proxy-service',
'connection-gateway',
+ 'agent-schedule-service',
];
for (const service_name of SERVICE_NAMES) {
diff --git a/rust/cloud-storage/scheduled_action/src/bins/service.rs b/rust/cloud-storage/scheduled_action/src/bins/service.rs
index 3f569d2b62..24b1b6de49 100644
--- a/rust/cloud-storage/scheduled_action/src/bins/service.rs
+++ b/rust/cloud-storage/scheduled_action/src/bins/service.rs
@@ -50,6 +50,8 @@ async fn main() -> Result<()> {
.await
.context("failed to connect to macrodb")?;
+ // TODO: This shoud be a config and use `macro_config` so we can
+ // have doppler tests for it.
let tool_context = build_tool_service_context_from_env(db.clone())
.await
.context("failed to build tool service context")?;