Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(infra): add typed shared-gateway listener priorities (#6127)
Will Hutchinson2e9d77088b0f
diff --git a/infra/packages/resources/src/resources/service_target_group.ts b/infra/packages/resources/src/resources/service_target_group.tsindex 0d94dc5c8a..6c7a90b888 100644--- a/infra/packages/resources/src/resources/service_target_group.ts+++ b/infra/packages/resources/src/resources/service_target_group.ts@@ -1,5 +1,6 @@import * as aws from '@pulumi/aws';import * as pulumi from '@pulumi/pulumi';+import { GATEWAY_PRIORITIES, type GatewayService } from '../../../shared';import {DEFAULT_DEREGISTRATION_DELAY_SECONDS,DEFAULT_TARGET_GROUP_HEALTH_CHECK,@@ -21,8 +22,11 @@ type ServiceTargetGroupArgs = {// Host headers to match instead of paths, for a target group that owns a// whole hostname on a shared listener.hostHeaders?: string[];- // Priority **MUST BE UNIQUE**- priority: number;+ // Shared-gateway tenant. Priority comes from GATEWAY_PRIORITIES.+ // Exactly one of service and priority must be set.+ service?: GatewayService;+ // Dedicated-ALB rule priority. Do not use on the shared gateway.+ priority?: number;// Health checkhealthCheck?: Partial<aws.types.input.lb.TargetGroupHealthCheck>;// Deregistration delay@@ -55,6 +59,16 @@ export class ServiceTargetGroup extends pulumi.ComponentResource {);}+ if (!args.service === !args.priority) {+ throw new Error(+ `${name}: exactly one of service and priority must be set`+ );+ }++ const priority = args.service+ ? GATEWAY_PRIORITIES[args.service]+ : args.priority;+this.target_group = new aws.lb.TargetGroup(`${name}-target-group`,{@@ -85,7 +99,7 @@ export class ServiceTargetGroup extends pulumi.ComponentResource {`${name}-listener-rule`,{listenerArn: args.listenerArn,- priority: args.priority,+ priority,conditions: [args.pathPatternsdiff --git a/infra/packages/shared/src/gateway_priorities.ts b/infra/packages/shared/src/gateway_priorities.tsnew file mode 100644index 0000000000..3cef2d5b6a--- /dev/null+++ b/infra/packages/shared/src/gateway_priorities.ts@@ -0,0 +1,25 @@+/**+ * Services attached to the shared gateway ALB listener.+ * Add a member when a service migrates onto the gateway.+ */+export enum GatewayService {+ DOCUMENT_STORAGE_SERVICE = 'DOCUMENT_STORAGE_SERVICE',+}++/**+ * Listener-rule priority for every gateway tenant.+ */+type GatewayPriorityMap = { [K in GatewayService]: number };++/**+ * Source of truth for shared-gateway ALB listener-rule priorities.+ * Values on this listener must be unique. A missing key is a compile error.+ */+export const GATEWAY_PRIORITIES: GatewayPriorityMap = {+ [GatewayService.DOCUMENT_STORAGE_SERVICE]: 10,+};++const assigned = Object.values(GATEWAY_PRIORITIES);+if (new Set(assigned).size !== assigned.length) {+ throw new Error('GATEWAY_PRIORITIES values must be unique');+}diff --git a/infra/packages/shared/src/index.ts b/infra/packages/shared/src/index.tsindex 56b2ef8533..20e0c1d133 100644--- a/infra/packages/shared/src/index.ts+++ b/infra/packages/shared/src/index.ts@@ -66,5 +66,6 @@ export {} from './ai_tools';export { getKafkaClusterPolicy } from './kafka_cluster_policy';export { getGatewayAlb, type GatewayAlb } from './gateway';+export { GATEWAY_PRIORITIES, GatewayService } from './gateway_priorities';export * from './service_urls';diff --git a/infra/stacks/cloud-storage-service/cloud-storage-service.ts b/infra/stacks/cloud-storage-service/cloud-storage-service.tsindex 8237952cac..7090f249b3 100644--- a/infra/stacks/cloud-storage-service/cloud-storage-service.ts+++ b/infra/stacks/cloud-storage-service/cloud-storage-service.ts@@ -21,6 +21,7 @@ import {getKafkaClusterPolicy,stack,getGatewayAlb,+ GatewayService,} from '../../packages/shared';const gatewayLoadBalancer = getGatewayAlb();@@ -315,7 +316,7 @@ export class CloudStorageService extends pulumi.ComponentResource {listenerArn: gatewayLoadBalancer.httpsListenerArn,vpcId: vpc.vpcId,containerPort: serviceContainerPort,- priority: 10,+ service: GatewayService.DOCUMENT_STORAGE_SERVICE,healthCheckPath,pathPatterns: ['/dss', '/dss/*'],serviceSecurityGroupId: this.serviceSg.id,