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
chore: remove dead infra code (#5474)
Will Hutchinson5344212b9185
diff --git a/infra/packages/service/src/jwt.ts b/infra/packages/service/src/jwt.tsdeleted file mode 100644index 13c5b50a85..0000000000--- a/infra/packages/service/src/jwt.ts+++ /dev/null@@ -1,62 +0,0 @@-import * as aws from '@pulumi/aws';-import * as pulumi from '@pulumi/pulumi';-import { stack } from '../../shared';--const JWT_SECRET_KEY = `fusionauth-jwt-secret-${stack}`;-export const ISSUER =- stack === 'prod' ? 'auth.macro.com' : 'fusionauth-dev.macro.com';-export const AUDIENCE =- stack === 'prod'- ? '75409999-7dc4-4241-b73b-a51818c3a71c'- : 'eb75fe7a-0ef1-4186-96d9-cc62cfb1d10c';--export class JwtSecretKeyIamPolicy extends pulumi.ComponentResource {- public readonly policy: aws.iam.Policy;- public readonly jwtSecretKeyArn: pulumi.Output<string>;-- constructor(- serviceName: string,- args: {- tags: Record<string, string>;- },- opts?: pulumi.ComponentResourceOptions- ) {- super(- `macro:cloud_storage:JwtSecretKeyIamPolicy`,- `${serviceName}-jwt-secret-key-iam-policy`,- args,- opts- );-- const jwtSecretKeyArn: pulumi.Output<string> = aws.secretsmanager- .getSecretOutput({ name: JWT_SECRET_KEY })- .apply((secret) => secret.arn);-- this.policy = new aws.iam.Policy(- `${serviceName}-jwt-secret-key-iam-policy`,- {- name: `${serviceName}-jwt-secret-key-iam-policy-${stack}`,- policy: {- Version: '2012-10-17',- Statement: [- {- Action: [- 'secretsmanager:GetSecretValue',- 'secretsmanager:DescribeSecret',- ],- Resource: [jwtSecretKeyArn],- Effect: 'Allow',- },- ],- },- tags: args.tags,- },- { parent: this }- );-- this.jwtSecretKeyArn = jwtSecretKeyArn;- this.registerOutputs({- jwtSecretKeyArn,- });- }-}diff --git a/infra/packages/service/src/load_balancer.ts b/infra/packages/service/src/load_balancer.tsdeleted file mode 100644index d933023552..0000000000--- a/infra/packages/service/src/load_balancer.ts+++ /dev/null@@ -1,195 +0,0 @@-// NOTE: this is an amalgamation of the load balancer and security groups that are effectively always created together--import * as aws from '@pulumi/aws';-import type * as awsx from '@pulumi/awsx';-import type { Input, Output } from '@pulumi/pulumi';-import * as pulumi from '@pulumi/pulumi';-import { serviceLoadBalancer as createServiceLoadBalancer } from '../../resources';-import { stack } from '../../shared';-import { COPARSE_API_VPC } from '../../vpc';--export class ServiceLoadBalancer extends pulumi.ComponentResource {- public readonly serviceSg: aws.ec2.SecurityGroup;- public readonly loadBalancer: aws.lb.LoadBalancer;- public readonly targetGroup: aws.alb.TargetGroup;- public readonly listener: aws.lb.Listener;-- public readonly serviceSgId: Output<string>;- public readonly loadBalancerArn: Output<string>;- public readonly serviceName: string;- public readonly port: number;-- constructor(- serviceName: string,- args: {- containerPort: number;- /**- * The path to use for the health check, defaults to `/health`- */- healthCheckPath?: string;- /**- * The VPC to create the load balancer in- * If not provided, the load balancer will be created in the Coparse API VPC- */- vpc?: {- vpcId: string;- publicSubnetIds: Input<string[]>;- privateSubnetIds: Input<string[]>;- };- isPrivate?: boolean;- tags?: Record<string, string>;- idleTimeout?: number;- healthCheck?: Partial<aws.types.input.lb.TargetGroupHealthCheck>;- deregistrationDelay?: number;- },- opts?: pulumi.ComponentResourceOptions- ) {- super(- 'macro:cloud_storage:ServiceWithLoadBalancer',- `${serviceName}-service-load-balancer-${stack}`,- args,- opts- );-- const {- containerPort: port,- isPrivate,- tags,- idleTimeout,- healthCheck,- deregistrationDelay,- } = args;- this.serviceName = serviceName;- const healthCheckPath = args.healthCheckPath ?? '/health';-- const vpc = args.vpc ?? COPARSE_API_VPC;- const vpcId = vpc.vpcId;-- const serviceAlbSg = new aws.ec2.SecurityGroup(- `${serviceName}-alb-sg-${stack}`,- {- name: `${serviceName}-alb-sg-${stack}`,- description: `${serviceName} application load balancer security group`,- vpcId,- tags,- },- { parent: this }- );-- const serviceSg = new aws.ec2.SecurityGroup(- `${serviceName}-sg-${stack}`,- {- name: `${serviceName}-sg-${stack}`,- vpcId,- description: `${serviceName} security group that is attached directly to the service`,- tags,- },- { parent: this }- );-- new aws.vpc.SecurityGroupIngressRule(- `${serviceName}-alb-in`,- {- securityGroupId: serviceSg.id,- description: 'Allow inbound traffic from the services ALB',- referencedSecurityGroupId: serviceAlbSg.id,- fromPort: port,- toPort: port,- ipProtocol: 'tcp',- tags,- },- { parent: this }- );-- new aws.vpc.SecurityGroupEgressRule(- `${serviceName}-all-out`,- {- securityGroupId: serviceSg.id,- description: 'Allow all outbound',- cidrIpv4: '0.0.0.0/0',- ipProtocol: '-1',- tags,- },- { parent: this }- );-- // ALB SG rules- new aws.vpc.SecurityGroupIngressRule(- `${serviceName}-http`,- {- securityGroupId: serviceAlbSg.id,- description: 'Allow inbound HTTP traffic',- cidrIpv4: '0.0.0.0/0',- fromPort: 80,- ipProtocol: 'tcp',- toPort: 80,- tags,- },- { parent: this }- );-- new aws.vpc.SecurityGroupIngressRule(- `${serviceName}-https`,- {- securityGroupId: serviceAlbSg.id,- description: 'Allow inbound HTTPS traffic',- cidrIpv4: '0.0.0.0/0',- fromPort: 443,- ipProtocol: 'tcp',- toPort: 443,- tags,- },- { parent: this }- );-- new aws.vpc.SecurityGroupEgressRule(- `${serviceName}-out-service`,- {- description: 'Allow traffic to the service security group',- securityGroupId: serviceAlbSg.id,- referencedSecurityGroupId: serviceSg.id,- fromPort: port,- ipProtocol: 'tcp',- toPort: port,- tags,- },- { parent: this }- );-- const { lb, targetGroup, listener } = createServiceLoadBalancer(this, {- serviceName,- serviceContainerPort: port,- healthCheckPath,- vpc: pulumi.output(vpc),- albSecurityGroupId: serviceAlbSg.id,- isPrivate,- tags: tags || {},- idleTimeout,- healthCheck,- deregistrationDelay,- });-- this.serviceSg = serviceSg;- this.loadBalancer = lb;- this.targetGroup = targetGroup;- this.listener = listener;-- this.serviceSgId = serviceSg.id;- this.loadBalancerArn = lb.arn;- this.port = port;- this.registerOutputs({- serviceSgId: serviceSg.id,- loadBalancerArn: lb.arn,- });- }-- public portMapping(): awsx.types.input.ecs.TaskDefinitionPortMappingArgs {- return {- appProtocol: 'http',- name: `${this.serviceName}-http-${stack}`,- containerPort: this.port,- hostPort: this.port,- targetGroup: this.targetGroup,- };- }-}diff --git a/infra/packages/service/src/route.ts b/infra/packages/service/src/route.tsdeleted file mode 100644index df5b0dbb51..0000000000--- a/infra/packages/service/src/route.ts+++ /dev/null@@ -1,48 +0,0 @@-import * as aws from '@pulumi/aws';-import * as pulumi from '@pulumi/pulumi';-import { BASE_DOMAIN, stack } from '../../shared';-import type { ServiceLoadBalancer } from './load_balancer';-export class ServiceRoute extends pulumi.ComponentResource {- public readonly domainName: string;- public readonly url: string;-- constructor(- serviceName: string,- args: { loadBalancer: ServiceLoadBalancer },- opts?: pulumi.ComponentResourceOptions- ) {- super(- `macro:cloud_storage:ServiceRoute`,- `${serviceName}-service-route-${stack}`,- {},- {- ...opts,- }- );- const zone = aws.route53.getZoneOutput({ name: BASE_DOMAIN });- const {- loadBalancer: { loadBalancer },- } = args;-- this.domainName = `${serviceName}${stack === 'prod' ? '' : `-${stack}`}`;-- new aws.route53.Record(- `${serviceName}-domain-record`,- {- name: this.domainName,- type: 'A',- zoneId: zone.zoneId,- aliases: [- {- evaluateTargetHealth: false,- name: loadBalancer.dnsName,- zoneId: loadBalancer.zoneId,- },- ],- },- { parent: this, dependsOn: [loadBalancer] }- );-- this.url = `https://${this.domainName}.${BASE_DOMAIN}`;- }-}diff --git a/infra/packages/service/src/service.ts b/infra/packages/service/src/service.tsdeleted file mode 100644index f209bf697e..0000000000--- a/infra/packages/service/src/service.ts+++ /dev/null@@ -1,155 +0,0 @@-import * as aws from '@pulumi/aws';-import * as awsx from '@pulumi/awsx';-import * as pulumi from '@pulumi/pulumi';-import {- DATADOG_API_KEY,- DEFAULT_CONTINUE_BEFORE_STEADY_STATE,- EcsDeploymentFailureAlarm,- datadogAgentContainer,- fargateLogRouterSidecarContainer,-} from '../../resources';-import { stack } from '../../shared';-import { COPARSE_API_VPC } from '../../vpc';-import { cloudStorageClusterArn } from './cluster';-import type { ServiceLoadBalancer } from './load_balancer';--function envVars(env: Record<string, pulumi.Input<string>>) {- const keys = Object.keys(env);- keys.sort();- return keys.map((key) => ({- name: key,- value: env[key],- }));-}--export class Service extends pulumi.ComponentResource {- public readonly service: awsx.ecs.FargateService;- public readonly serviceName: pulumi.Output<string>;- public readonly role: aws.iam.Role;-- constructor(- serviceName: string,- args: {- loadBalancer: ServiceLoadBalancer;- iamPolicies: aws.iam.Policy[];- imageRef: pulumi.Input<string>;- environment?: Record<string, pulumi.Input<string>>;-- /** if true, the service will not have a datadog agent or log router sidecar */- noDatadog?: boolean;- vpc?: {- vpcId: string;- publicSubnetIds: string[];- privateSubnetIds: string[];- };- ecsClusterArn?: string;- continueBeforeSteadyState?: boolean;- sidecarContainers?: Record<- string,- awsx.types.input.ecs.TaskDefinitionContainerDefinitionArgs- >;- tags: Record<string, string>;- },- opts?: pulumi.ComponentResourceOptions- ) {- super(- `macro:cloud_storage:Service`,- `${serviceName}-service-${stack}`,- args,- opts- );- const { loadBalancer, iamPolicies } = args;- const vpc = args.vpc ?? COPARSE_API_VPC;-- this.role = new aws.iam.Role(- `${serviceName}-role-${stack}`,- {- assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({- Service: 'ecs-tasks.amazonaws.com',- }),- managedPolicyArns: iamPolicies.map((policy) => policy.arn),- tags: args.tags,- },- { parent: this }- );-- this.service = new awsx.ecs.FargateService(- serviceName,- {- cluster: args.ecsClusterArn ?? cloudStorageClusterArn,- networkConfiguration: {- subnets: vpc.privateSubnetIds,- securityGroups: [loadBalancer.serviceSgId],- },- continueBeforeSteadyState:- args.continueBeforeSteadyState ??- DEFAULT_CONTINUE_BEFORE_STEADY_STATE,- deploymentCircuitBreaker: {- enable: true,- rollback: true,- },- taskDefinitionArgs: {- taskRole: {- roleArn: this.role.arn,- },- containers: {- ...args.sidecarContainers,- ...(args.noDatadog- ? {}- : {- datadog_agent: datadogAgentContainer,- log_router: fargateLogRouterSidecarContainer,- }),- service: {- name: serviceName,- image: args.imageRef,- cpu: 1024,- memory: 512,- environment: args.environment- ? envVars(args.environment)- : undefined,- logConfiguration: args.noDatadog- ? undefined- : {- logDriver: 'awsfirelens',- options: {- Name: 'datadog',- Host: 'http-intake.logs.us5.datadoghq.com',- apikey: DATADOG_API_KEY,- dd_service: `${serviceName}-${stack}`,- dd_source: 'fargate',- dd_tags: `project:${serviceName}`,- provider: 'ecs',- },- },- portMappings: [loadBalancer.portMapping()],- },- },- },- },- {- parent: this,- dependsOn: [- loadBalancer,- loadBalancer.targetGroup,- ...args.iamPolicies,- ],- }- );-- new EcsDeploymentFailureAlarm(- `${serviceName}-deployment-failure`,- {- serviceName,- serviceArn: this.service.service.arn,- tags: args.tags,- },- { parent: this }- );-- this.serviceName = this.service.service.name;- this.registerOutputs({- name: this.service.service.name,- });- }-}diff --git a/infra/packages/service/src/service_alarms.ts b/infra/packages/service/src/service_alarms.tsdeleted file mode 100644index db50f4d8a2..0000000000--- a/infra/packages/service/src/service_alarms.ts+++ /dev/null@@ -1,93 +0,0 @@-import * as aws from '@pulumi/aws';-import * as pulumi from '@pulumi/pulumi';-import { CLOUD_TRAIL_SNS_TOPIC_ARN, stack } from '../../shared';-import { cloudStorageClusterName } from './cluster';-import type { ServiceLoadBalancer } from './load_balancer';-import type { Service } from './service';--export class ServiceAlarms extends pulumi.ComponentResource {- constructor(- serviceName: string,- args: {- service: Service;- loadBalancer: ServiceLoadBalancer;- tags: Record<string, string>;- },- opts?: pulumi.ComponentResourceOptions- ) {- super(- `macro:cloud_storage:ServiceAlarms`,- `${serviceName}-service-alarms-${stack}`,- args,- opts- );- const { service, loadBalancer, tags } = args;- new aws.cloudwatch.MetricAlarm(- `${serviceName}-high-cpu-alarm`,- {- name: `${serviceName}-high-cpu-alarm-${stack}`,- metricName: 'CPUUtilization',- namespace: 'AWS/ECS',- statistic: 'Maximum',- period: 180,- evaluationPeriods: 1,- threshold: 60,- comparisonOperator: 'GreaterThanThreshold',- dimensions: {- ClusterName: cloudStorageClusterName,- ServiceName: service.serviceName,- },- alarmDescription: `High CPU usage alarm for ${serviceName} service.`,- actionsEnabled: true,- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],- tags: tags,- },- { parent: this, dependsOn: [service.service, loadBalancer] }- );-- new aws.cloudwatch.MetricAlarm(- `${serviceName}-high-mem-alarm`,- {- name: `${serviceName}-high-mem-alarm-${stack}`,- metricName: 'MemoryUtilization',- namespace: 'AWS/ECS',- statistic: 'Maximum',- period: 180,- evaluationPeriods: 1,- threshold: 80,- comparisonOperator: 'GreaterThanThreshold',- dimensions: {- ClusterName: cloudStorageClusterName,- ServiceName: service.serviceName,- },- alarmDescription: `High Memory usage alarm for ${serviceName} service.`,- actionsEnabled: true,- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],- tags: tags,- },- { parent: this, dependsOn: [service.service, loadBalancer] }- );-- new aws.cloudwatch.MetricAlarm(- `${serviceName}-http-5xx-alarm`,- {- name: `${serviceName}-http-5xx-${stack}`,- metricName: 'HTTPCode_ELB_5XX_Count',- namespace: 'AWS/ApplicationELB',- statistic: 'Sum',- period: 180,- evaluationPeriods: 1,- threshold: 25,- comparisonOperator: 'GreaterThanOrEqualToThreshold',- dimensions: {- LoadBalancer: loadBalancer.loadBalancerArn,- },- alarmDescription: `High HTTP 5XX count alarm for ${serviceName} Load Balancer.`,- actionsEnabled: true,- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],- tags: tags,- },- { parent: this, dependsOn: [service.service, loadBalancer] }- );- }-}diff --git a/infra/packages/service/src/service_autoscaling.ts b/infra/packages/service/src/service_autoscaling.tsdeleted file mode 100644index 5475495964..0000000000--- a/infra/packages/service/src/service_autoscaling.ts+++ /dev/null@@ -1,128 +0,0 @@-import * as aws from '@pulumi/aws';-import * as pulumi from '@pulumi/pulumi';-import { stack } from '../../shared';-import { cloudStorageClusterName } from './cluster';-import type { ServiceLoadBalancer } from './load_balancer';-import type { Service } from './service';--export class ServiceAutoscaling extends pulumi.ComponentResource {- constructor(- serviceName: string,- args: {- service: Service;- loadBalancer: ServiceLoadBalancer;- tags: Record<string, string>;- },- opts?: pulumi.ComponentResourceOptions- ) {- super(- `macro:cloud_storage:ServiceAutoscaling`,- `${serviceName}-service-autoscaling-${stack}`,- args,- opts- );- const { service, loadBalancer, tags } = args;-- const serviceScalableTarget = new aws.appautoscaling.Target(- `${serviceName}-service-scalable-target-${stack}`,- {- maxCapacity: stack === 'prod' ? 15 : 3,- minCapacity: stack === 'prod' ? 6 : 1,- resourceId: pulumi.interpolate`service/${cloudStorageClusterName}/${service.serviceName}`,- scalableDimension: 'ecs:service:DesiredCount',- serviceNamespace: 'ecs',- tags,- },- { parent: this, dependsOn: [service.service] }- );-- const lbPortion: pulumi.Output<string> = loadBalancer.loadBalancerArn.apply(- (arn) => {- const parts = arn.split(':loadbalancer/');- return parts[1];- }- );-- const tgPortion: pulumi.Output<string> = loadBalancer.targetGroup.arn.apply(- (arn) => {- const parts = arn.split(':');- return parts[parts.length - 1];- }- );-- const resourceLabel = pulumi.interpolate`${lbPortion}/${tgPortion}`;-- // Create an Auto Scaling policy for request count.- new aws.appautoscaling.Policy(- `${serviceName}-scaling-policy-request-count-${stack}`,- {- policyType: 'TargetTrackingScaling',- resourceId: serviceScalableTarget.resourceId,- scalableDimension: serviceScalableTarget.scalableDimension,- serviceNamespace: serviceScalableTarget.serviceNamespace,- targetTrackingScalingPolicyConfiguration: {- targetValue: 1000, // TODO: play with this- predefinedMetricSpecification: {- predefinedMetricType: 'ALBRequestCountPerTarget',- resourceLabel,- },- scaleInCooldown: 100,- scaleOutCooldown: 120,- },- },- { parent: this, dependsOn: [service.service, loadBalancer.targetGroup] }- );-- // Create an Auto Scaling policy for CPU utilization.- new aws.appautoscaling.Policy(- `${serviceName}-scaling-policy-cpu-${stack}`,- {- policyType: 'TargetTrackingScaling',- resourceId: serviceScalableTarget.resourceId,- scalableDimension: serviceScalableTarget.scalableDimension,- serviceNamespace: serviceScalableTarget.serviceNamespace,- targetTrackingScalingPolicyConfiguration: {- targetValue: 50.0,- customizedMetricSpecification: {- metricName: 'CPUUtilization',- namespace: 'AWS/ECS',- dimensions: [- {- name: 'ClusterName',- value: pulumi.interpolate`${cloudStorageClusterName}`,- },- {- name: 'ServiceName',- value: pulumi.interpolate`${service.serviceName}`,- },- ],- statistic: 'Maximum',- unit: 'Percent',- },- scaleInCooldown: 100,- scaleOutCooldown: 120,- },- },- { parent: this, dependsOn: [service.service, loadBalancer.targetGroup] }- );-- new aws.appautoscaling.Policy(- `${serviceName}-scaling-policy-memory-${stack}`,- {- policyType: 'TargetTrackingScaling',- resourceId: serviceScalableTarget.resourceId,- scalableDimension: serviceScalableTarget.scalableDimension,- serviceNamespace: serviceScalableTarget.serviceNamespace,- targetTrackingScalingPolicyConfiguration: {- targetValue: 70.0,- predefinedMetricSpecification: {- predefinedMetricType: 'ECSServiceAverageMemoryUtilization',- },- scaleInCooldown: 100,- scaleOutCooldown: 300,- },- },- { parent: this, dependsOn: [service.service, loadBalancer.targetGroup] }- );- }-}