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.

remove search and comms service infra (#1313)

Will Hutchinson9f866f8f0134
diff --git a/infra/bun.lock b/infra/bun.lock
index 5e9ec0ad5e..f7528b4b90 100644
--- a/infra/bun.lock
+++ b/infra/bun.lock
@@ -59,10 +59,6 @@
"name": "cloud-storage-service-stack",
"version": "0.0.0",
},
- "stacks/comms-service": {
- "name": "comms-service-stack",
- "version": "0.0.0",
- },
"stacks/connection-gateway": {
"name": "connection-gateway-stack",
"version": "0.0.0",
@@ -150,10 +146,6 @@
"name": "search-processing-service-stack",
"version": "0.0.0",
},
- "stacks/search-service": {
- "name": "search-service-stack",
- "version": "0.0.0",
- },
"stacks/search-text-extractor-queue": {
"name": "search-text-extractor-queue-stack",
"version": "0.0.0",
@@ -574,8 +566,6 @@
"common-ancestor-path": ["[email protected]", "", {}, "sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w=="],
- "comms-service-stack": ["comms-service-stack@workspace:stacks/comms-service"],
-
"connection-gateway-stack": ["connection-gateway-stack@workspace:stacks/connection-gateway"],
"contacts-service-stack": ["contacts-service-stack@workspace:stacks/contacts-service"],
@@ -888,8 +878,6 @@
"search-processing-service-stack": ["search-processing-service-stack@workspace:stacks/search-processing-service"],
- "search-service-stack": ["search-service-stack@workspace:stacks/search-service"],
-
"search-text-extractor-queue-stack": ["search-text-extractor-queue-stack@workspace:stacks/search-text-extractor-queue"],
"search-upload-stack": ["search-upload-stack@workspace:stacks/search-upload"],
diff --git a/infra/stacks/comms-service/Pulumi.dev.yaml b/infra/stacks/comms-service/Pulumi.dev.yaml
deleted file mode 100644
index c6a6765103..0000000000
--- a/infra/stacks/comms-service/Pulumi.dev.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-config:
- aws-native:region: us-east-1
- aws:region: us-east-1
- comms-service:comms_db_password_key: comms-db-password-dev
- comms-service:fusionauth_client_id: fusionauth-client-id-key-dev
- comms-service:fusionauth_issuer: fusionauth-dev.macro.com
- comms-service:internal_auth_key: document-storage-service-auth-key-dev
- comms-service:jwt_secret_key: fusionauth-jwt-secret-dev
- comms-service:legacy_jwt_secret_key: jwt-secret-dev
- comms-service:macro_db_secret_key: macro-db-dev
- comms-service:authentication_service_secret_key: authentication-service-internal-api-key-dev
- comms-service:document_storage_permissions_key: document-storage-permissions-key-dev
diff --git a/infra/stacks/comms-service/Pulumi.prod.yaml b/infra/stacks/comms-service/Pulumi.prod.yaml
deleted file mode 100644
index 65401c2be2..0000000000
--- a/infra/stacks/comms-service/Pulumi.prod.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-config:
- aws-native:region: us-east-1
- aws:region: us-east-1
- comms-service:comms_db_password_key: comms-db-password-prod
- comms-service:fusionauth_client_id: fusionauth-client-id-key-prod
- comms-service:fusionauth_issuer: auth.macro.com
- comms-service:internal_auth_key: document-storage-service-auth-key-prod
- comms-service:jwt_secret_key: fusionauth-jwt-secret-prod
- comms-service:legacy_jwt_secret_key: jwt-secret-prod
- comms-service:macro_db_secret_key: macro-db-prod
- comms-service:authentication_service_secret_key: authentication-service-internal-api-key-prod
- comms-service:document_storage_permissions_key: document-storage-permissions-key-prod
diff --git a/infra/stacks/comms-service/Pulumi.yaml b/infra/stacks/comms-service/Pulumi.yaml
deleted file mode 100644
index c4c02a6348..0000000000
--- a/infra/stacks/comms-service/Pulumi.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-name: comms-service
-runtime: nodejs
-description: Comms Service
diff --git a/infra/stacks/comms-service/comms-service.ts b/infra/stacks/comms-service/comms-service.ts
deleted file mode 100644
index 62e70a421f..0000000000
--- a/infra/stacks/comms-service/comms-service.ts
+++ /dev/null
@@ -1,545 +0,0 @@
-import * as aws from '@pulumi/aws';
-import * as awsx from '@pulumi/awsx';
-import * as pulumi from '@pulumi/pulumi';
-import {
- createFrecencyTablePolicy,
- DATADOG_API_KEY,
- datadogAgentContainer,
- fargateLogRouterSidecarContainer,
- serviceLoadBalancer,
-} from '../../packages/resources';
-import { EcrImage } from '../../packages/service';
-import {
- BASE_DOMAIN,
- CLOUD_TRAIL_SNS_TOPIC_ARN,
- stack,
-} from '../../packages/shared';
-
-const BASE_NAME = 'comms-service';
-const BASE_PATH = '../../../rust/cloud-storage';
-
-export const SERVICE_DOMAIN_NAME = `comms-service${
- stack === 'prod' ? '' : `-${stack}`
-}.${BASE_DOMAIN}`;
-
-type CreateCommsServiceArgs = {
- cloudStorageClusterName: pulumi.Output<string> | string;
- ecsClusterArn: pulumi.Output<string> | string;
- vpc: {
- vpcId: pulumi.Output<string> | string;
- publicSubnetIds: pulumi.Output<string[]> | string[];
- privateSubnetIds: pulumi.Output<string[]> | string[];
- };
- platform: { family: string; architecture: 'amd64' | 'arm64' };
- serviceContainerPort: number;
- isPrivate?: boolean;
- containerEnvVars?: { name: string; value: pulumi.Output<string> | string }[];
- healthCheckPath: string;
- tags: { [key: string]: string };
- queueArns: (pulumi.Output<string> | string)[];
- secretKeyArns: (pulumi.Output<string> | string)[];
-};
-
-export class CommsService extends pulumi.ComponentResource {
- public ecr: awsx.ecr.Repository;
- public serviceAlbSg: aws.ec2.SecurityGroup;
- public serviceSg: aws.ec2.SecurityGroup;
- public targetGroup: aws.lb.TargetGroup;
- public lb: aws.lb.LoadBalancer;
- public listener: aws.lb.Listener;
- public service: awsx.ecs.FargateService;
- public domain: string;
- public cloudStorageClusterName: pulumi.Output<string> | string;
- public tags: { [key: string]: string };
- public role: aws.iam.Role;
-
- constructor(
- name: string,
- {
- ecsClusterArn,
- vpc,
- platform,
- serviceContainerPort,
- healthCheckPath,
- isPrivate,
- containerEnvVars,
- cloudStorageClusterName,
- tags,
- secretKeyArns,
- queueArns,
- }: CreateCommsServiceArgs,
- opts?: pulumi.ComponentResourceOptions
- ) {
- super('my:components:CommsService', name, {}, opts);
- this.tags = tags;
-
- this.cloudStorageClusterName = cloudStorageClusterName;
-
- // ecr image
- const image = new EcrImage(
- `${BASE_NAME}-ecr-image-${stack}`,
- {
- repositoryId: `${BASE_NAME}-ecr-${stack}`,
- repositoryName: `${BASE_NAME}-${stack}`,
- imageId: `${BASE_NAME}-image-${stack}`,
- imagePath: BASE_PATH,
- dockerfile: 'Dockerfile',
- platform,
- buildArgs: {
- SERVICE_NAME: 'comms_service',
- },
- tags: this.tags,
- },
- { parent: this }
- );
- this.ecr = image.ecr;
-
- // sg
- const sg = this.initializeSecurityGroups({
- vpcId: vpc.vpcId,
- serviceContainerPort,
- });
- this.serviceAlbSg = sg.serviceAlbSg;
- this.serviceSg = sg.serviceSg;
-
- // lb
- const { targetGroup, lb, listener } = serviceLoadBalancer(this, {
- serviceName: BASE_NAME, // service name
- serviceContainerPort,
- healthCheckPath,
- vpc,
- albSecurityGroupId: this.serviceAlbSg.id,
- isPrivate,
- tags,
- idleTimeout: 3600,
- });
- this.targetGroup = targetGroup;
- this.lb = lb;
- this.listener = listener;
-
- const secretsManagerPolicy = new aws.iam.Policy(
- `${BASE_NAME}-secrets-manager-policy`,
- {
- name: `${BASE_NAME}-secrets-manager-policy-${stack}`,
- policy: {
- Version: '2012-10-17',
- Statement: [
- {
- Action: [
- 'secretsmanager:GetSecretValue',
- 'secretsmanager:DescribeSecret',
- ],
- Resource: [...secretKeyArns],
- Effect: 'Allow',
- },
- ],
- },
- tags: this.tags,
- },
- { parent: this }
- );
-
- const queuePolicy = new aws.iam.Policy(
- `${BASE_NAME}-sqs-policy`,
- {
- name: `${BASE_NAME}-sqs-policy-${stack}`,
- policy: {
- Version: '2012-10-17',
- Statement: [
- {
- Action: ['sqs:SendMessage'],
- Resource: queueArns,
- Effect: 'Allow',
- },
- ],
- },
- tags: this.tags,
- },
- { parent: this }
- );
-
- // Create frecency table policy
- const frecencyPolicy = createFrecencyTablePolicy(
- `${BASE_NAME}-frecency-policy`,
- { parent: this }
- );
-
- this.role = new aws.iam.Role(
- `${BASE_NAME}-role`,
- {
- name: `${BASE_NAME}-role-${stack}`,
- assumeRolePolicy: {
- Version: '2012-10-17',
- Statement: [
- {
- Action: 'sts:AssumeRole',
- Principal: {
- Service: 'ecs-tasks.amazonaws.com',
- },
- Effect: 'Allow',
- Sid: '',
- },
- ],
- },
- managedPolicyArns: [
- secretsManagerPolicy.arn,
- queuePolicy.arn,
- frecencyPolicy.arn,
- ],
- tags: this.tags,
- },
- { parent: this }
- );
-
- // service
- const service = new awsx.ecs.FargateService(
- `${BASE_NAME}`,
- {
- tags,
- cluster: ecsClusterArn,
- networkConfiguration: {
- subnets: vpc.privateSubnetIds,
- securityGroups: [this.serviceSg.id],
- },
- taskDefinitionArgs: {
- taskRole: {
- roleArn: this.role.arn,
- },
- containers: {
- log_router: fargateLogRouterSidecarContainer,
- datadog_agent: datadogAgentContainer,
- service: {
- name: BASE_NAME,
- image: image.image.imageUri,
- stopTimeout: 10, // 10 seconds to force kill the task
- cpu: 4096,
- memory: 8192,
- environment: containerEnvVars,
- logConfiguration: {
- logDriver: 'awsfirelens',
- options: {
- Name: 'datadog',
- Host: 'http-intake.logs.us5.datadoghq.com',
- apikey: DATADOG_API_KEY,
- dd_service: `comms-service-${stack}`,
- dd_source: 'fargate',
- dd_tags: `project:comms-service, env:${stack}`,
- provider: 'ecs',
- },
- },
- portMappings: [
- {
- appProtocol: 'http',
- name: `${BASE_NAME}-tcp-${stack}`,
- hostPort: serviceContainerPort,
- containerPort: serviceContainerPort,
- targetGroup,
- },
- ],
- },
- },
- runtimePlatform: {
- operatingSystemFamily: `${platform.family.toUpperCase()}`,
- cpuArchitecture: `${
- platform.architecture === 'amd64'
- ? 'X86_64'
- : platform.architecture.toUpperCase()
- }`,
- },
- },
- desiredCount: stack === 'prod' ? 3 : 1,
- },
- { parent: this }
- );
-
- this.service = service;
-
- this.setupAutoScaling();
-
- this.setupServiceAlarms();
-
- // domain record
- const zone = aws.route53.getZoneOutput({ name: BASE_DOMAIN });
-
- new aws.route53.Record(
- `${BASE_NAME}-domain-record`,
- {
- name: `${SERVICE_DOMAIN_NAME}`,
- type: 'A',
- zoneId: zone.zoneId,
- aliases: [
- {
- evaluateTargetHealth: false,
- name: this.lb.dnsName,
- zoneId: this.lb.zoneId,
- },
- ],
- },
- { parent: this }
- );
-
- this.domain = `https://${SERVICE_DOMAIN_NAME}`;
- }
-
- initializeSecurityGroups({
- vpcId,
- serviceContainerPort,
- }: {
- vpcId: pulumi.Output<string> | string;
- serviceContainerPort: number;
- }) {
- const serviceAlbSg = new aws.ec2.SecurityGroup(
- `${BASE_NAME}-alb-sg-${stack}`,
- {
- name: `${BASE_NAME}-alb-sg-${stack}`,
- description: `${BASE_NAME} application load balancer security group`,
- vpcId,
- tags: this.tags,
- },
- { parent: this }
- );
-
- const serviceSg = new aws.ec2.SecurityGroup(
- `${BASE_NAME}-sg-${stack}`,
- {
- name: `${BASE_NAME}-sg-${stack}`,
- vpcId,
- description: `${BASE_NAME} security group that is attached directly to the service`,
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.vpc.SecurityGroupIngressRule(
- `${BASE_NAME}-alb-in`,
- {
- securityGroupId: serviceSg.id,
- description: 'Allow inbound traffic from the services ALB',
- referencedSecurityGroupId: serviceAlbSg.id,
- fromPort: serviceContainerPort,
- toPort: serviceContainerPort,
- ipProtocol: 'tcp',
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.vpc.SecurityGroupEgressRule(
- `${BASE_NAME}-all-out`,
- {
- securityGroupId: serviceSg.id,
- description: 'Allow all outbound',
- cidrIpv4: '0.0.0.0/0',
- ipProtocol: '-1',
- tags: this.tags,
- },
- { parent: this }
- );
-
- // ALB SG rules
- new aws.vpc.SecurityGroupIngressRule(
- `${BASE_NAME}-http`,
- {
- securityGroupId: serviceAlbSg.id,
- description: 'Allow inbound HTTP traffic',
- cidrIpv4: '0.0.0.0/0',
- fromPort: 80,
- ipProtocol: 'tcp',
- toPort: 80,
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.vpc.SecurityGroupIngressRule(
- `${BASE_NAME}-https`,
- {
- securityGroupId: serviceAlbSg.id,
- description: 'Allow inbound HTTPS traffic',
- cidrIpv4: '0.0.0.0/0',
- fromPort: 443,
- ipProtocol: 'tcp',
- toPort: 443,
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.vpc.SecurityGroupEgressRule(
- `${BASE_NAME}-out-service`,
- {
- description: 'Allow traffic to the service security group',
- securityGroupId: serviceAlbSg.id,
- referencedSecurityGroupId: serviceSg.id,
- fromPort: serviceContainerPort,
- ipProtocol: 'tcp',
- toPort: serviceContainerPort,
- tags: this.tags,
- },
- { parent: this }
- );
-
- return { serviceAlbSg, serviceSg };
- }
-
- setupAutoScaling() {
- if (!this.service) return;
-
- const serviceScalableTarget = new aws.appautoscaling.Target(
- `${BASE_NAME}-service-scalable-target-${stack}`,
- {
- maxCapacity: stack === 'prod' ? 15 : 3,
- minCapacity: stack === 'prod' ? 3 : 1,
- resourceId: pulumi.interpolate`service/${this.cloudStorageClusterName}/${this.service.service.name}`,
- scalableDimension: 'ecs:service:DesiredCount',
- serviceNamespace: 'ecs',
- tags: this.tags,
- },
- { parent: this }
- );
-
- const lbPortion: pulumi.Output<string> = this.lb.arn.apply((arn) => {
- const parts = arn.split(':loadbalancer/');
- return parts[1];
- });
-
- const tgPortion: pulumi.Output<string> = this.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(
- `${BASE_NAME}-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: 60,
- scaleOutCooldown: 120,
- },
- },
- { parent: this }
- );
-
- // Create an Auto Scaling policy for CPU utilization.
- new aws.appautoscaling.Policy(
- `${BASE_NAME}-scaling-policy-cpu-${stack}`,
- {
- policyType: 'TargetTrackingScaling',
- resourceId: serviceScalableTarget.resourceId,
- scalableDimension: serviceScalableTarget.scalableDimension,
- serviceNamespace: serviceScalableTarget.serviceNamespace,
- targetTrackingScalingPolicyConfiguration: {
- targetValue: 70.0,
- predefinedMetricSpecification: {
- predefinedMetricType: 'ECSServiceAverageCPUUtilization',
- },
- scaleInCooldown: 100,
- scaleOutCooldown: 300,
- },
- },
- { parent: this }
- );
-
- new aws.appautoscaling.Policy(
- `${BASE_NAME}-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 }
- );
- }
-
- setupServiceAlarms() {
- new aws.cloudwatch.MetricAlarm(
- `${BASE_NAME}-high-cpu-alarm`,
- {
- name: `${BASE_NAME}-high-cpu-alarm-${stack}`,
- metricName: 'CPUUtilization',
- namespace: 'AWS/ECS',
- statistic: 'Average',
- period: 180,
- evaluationPeriods: 1,
- threshold: 80,
- comparisonOperator: 'GreaterThanThreshold',
- dimensions: {
- ClusterName: this.cloudStorageClusterName,
- ServiceName: this.service.service.name,
- },
- alarmDescription: `High CPU usage alarm for ${BASE_NAME} service.`,
- actionsEnabled: true,
- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.cloudwatch.MetricAlarm(
- `${BASE_NAME}-high-mem-alarm`,
- {
- name: `${BASE_NAME}-high-mem-alarm-${stack}`,
- metricName: 'MemoryUtilization',
- namespace: 'AWS/ECS',
- statistic: 'Average',
- period: 180,
- evaluationPeriods: 1,
- threshold: 80,
- comparisonOperator: 'GreaterThanThreshold',
- dimensions: {
- ClusterName: this.cloudStorageClusterName,
- ServiceName: this.service.service.name,
- },
- alarmDescription: `High Memory usage alarm for ${BASE_NAME} service.`,
- actionsEnabled: true,
- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.cloudwatch.MetricAlarm(
- `${BASE_NAME}-http-5xx-alarm`,
- {
- name: `${BASE_NAME}-http-5xx-${stack}`,
- metricName: 'HTTPCode_ELB_5XX_Count',
- namespace: 'AWS/ApplicationELB',
- statistic: 'Sum',
- period: 180,
- evaluationPeriods: 1,
- threshold: 25,
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
- dimensions: {
- LoadBalancer: this.lb.arn,
- },
- alarmDescription: `High HTTP 5XX count alarm for ${BASE_NAME} Load Balancer.`,
- actionsEnabled: true,
- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],
- tags: this.tags,
- },
- { parent: this }
- );
- }
-}
diff --git a/infra/stacks/comms-service/index.ts b/infra/stacks/comms-service/index.ts
deleted file mode 100644
index 6c7d459b56..0000000000
--- a/infra/stacks/comms-service/index.ts
+++ /dev/null
@@ -1,222 +0,0 @@
-import * as aws from '@pulumi/aws';
-import * as pulumi from '@pulumi/pulumi';
-import {
- config,
- getMacroApiToken,
- getMacroNotify,
- getSearchEventQueue,
- stack,
-} from '../../packages/shared';
-import { get_coparse_api_vpc } from '../../packages/vpc';
-import { CommsService } from './comms-service';
-
-const tags = {
- environment: stack,
- tech_lead: 'teo',
- project: 'comms-service',
-};
-
-export const coparse_api_vpc = get_coparse_api_vpc();
-
-const LEGACY_JWT_SECRET = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.get(`legacy_jwt_secret_key`) ?? '',
- })
- .apply((secret) => secret.secretString);
-
-const AUTHENTICATION_SERVICE_SECRET_KEY = config.require(
- `authentication_service_secret_key`
-);
-const authenticationServiceSecretKey: pulumi.Output<string> = aws.secretsmanager
- .getSecretVersionOutput({ secretId: AUTHENTICATION_SERVICE_SECRET_KEY })
- .apply((secret) => secret.arn);
-const JWT_SECRET_KEY = config.require(`jwt_secret_key`);
-const jwtSecretKeyArn: pulumi.Output<string> = aws.secretsmanager
- .getSecretVersionOutput({ secretId: JWT_SECRET_KEY })
- .apply((secret) => secret.arn);
-
-const MACRO_DB_URL_SECRET_NAME = config.require(`macro_db_secret_key`);
-const MACRO_DB_URL = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: MACRO_DB_URL_SECRET_NAME,
- })
- .apply((secret) => secret.secretString);
-const macroDbUrlArn: pulumi.Output<string> = aws.secretsmanager
- .getSecretVersionOutput({ secretId: MACRO_DB_URL_SECRET_NAME })
- .apply((secret) => secret.arn);
-
-const fusionauthClientIdSecretKey = config.require(`fusionauth_client_id`);
-
-const FUSIONAUTH_CLIENT_ID = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: fusionauthClientIdSecretKey,
- })
- .apply((secret) => secret.secretString);
-const FUSIONAUTH_ISSUER = config.require(`fusionauth_issuer`);
-
-const INTERNAL_AUTH_KEY = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.get(`internal_auth_key`) ?? '',
- })
- .apply((secret) => secret.secretString);
-
-const DOCUMENT_STORAGE_PERMISSIONS_KEY = config.require(
- `document_storage_permissions_key`
-);
-const documentStoragePermissionsKeyArn: pulumi.Output<string> =
- aws.secretsmanager
- .getSecretVersionOutput({ secretId: DOCUMENT_STORAGE_PERMISSIONS_KEY })
- .apply((secret) => secret.arn);
-
-const cloudStorageStack = new pulumi.StackReference('cloud-storage-stack', {
- name: `macro-inc/document-storage/${stack}`,
-});
-
-const connectionGatewayStack = new pulumi.StackReference(
- 'connection-gateway-stack',
- {
- name: `macro-inc/connection-gateway/${stack}`,
- }
-);
-
-const connectionGatewayEndpoint = connectionGatewayStack
- .getOutput('connectionGatewayUrl')
- .apply((arn) => arn as string);
-
-const cloudStorageClusterArn: pulumi.Output<string> = cloudStorageStack
- .getOutput('cloudStorageClusterArn')
- .apply((arn) => arn as string);
-
-const cloudStorageClusterName: pulumi.Output<string> = cloudStorageStack
- .getOutput('cloudStorageClusterName')
- .apply((arn) => arn as string);
-
-const { notificationQueueName, notificationQueueArn } = getMacroNotify();
-
-// Retrieve name of queue used Contacts Service
-const contactsServiceStack: pulumi.StackReference = new pulumi.StackReference(
- 'contacts-service-stack',
- {
- name: `macro-inc/contacts-service/${stack}`,
- }
-);
-
-const contactsQueueName: pulumi.Output<string> = contactsServiceStack
- .getOutput('contactsQueueName')
- .apply((arn) => arn as string);
-
-// Get ARN to allow sending messages to contacts Queue
-const contactsQueueArn: pulumi.Output<string> = contactsServiceStack
- .getOutput('contactsQueueArn')
- .apply((arn) => arn as string);
-
-const { searchEventQueueName, searchEventQueueArn } = getSearchEventQueue();
-
-const MACRO_API_TOKENS = getMacroApiToken();
-
-const secretKeyArns = [
- pulumi.interpolate`${jwtSecretKeyArn}`,
- pulumi.interpolate`${authenticationServiceSecretKey}`,
- pulumi.interpolate`${documentStoragePermissionsKeyArn}`,
- pulumi.interpolate`${macroDbUrlArn}`,
- pulumi.interpolate`${MACRO_API_TOKENS.macroApiTokenPublicKeyArn}`,
-];
-
-const queueArns = [
- pulumi.interpolate`${notificationQueueArn}`,
- pulumi.interpolate`${contactsQueueArn}`,
- pulumi.interpolate`${searchEventQueueArn}`,
-];
-
-const commsService = new CommsService(`comms-service-${stack}`, {
- ecsClusterArn: cloudStorageClusterArn,
- cloudStorageClusterName: cloudStorageClusterName,
- vpc: coparse_api_vpc,
- platform: {
- family: 'linux',
- architecture: 'amd64',
- },
- queueArns,
- serviceContainerPort: 8080,
- healthCheckPath: '/health',
- containerEnvVars: [
- {
- name: 'DATABASE_URL',
- value: pulumi.interpolate`${MACRO_DB_URL}`,
- },
- {
- name: 'ENVIRONMENT',
- value: stack,
- },
- {
- name: 'RUST_LOG',
- value: `comms_service=${
- stack === 'prod' ? 'info' : 'debug'
- },tower_http=info,document_storage_service_client=info`,
- },
- {
- name: 'LEGACY_JWT_SECRET',
- value: pulumi.interpolate`${LEGACY_JWT_SECRET}`,
- },
- {
- name: 'INTERNAL_API_SECRET_KEY',
- value: pulumi.interpolate`${INTERNAL_AUTH_KEY}`,
- },
- { name: 'ISSUER', value: pulumi.interpolate`${FUSIONAUTH_ISSUER}` },
- {
- name: 'JWT_SECRET_KEY',
- value: pulumi.interpolate`${JWT_SECRET_KEY}`,
- },
- {
- name: 'AUDIENCE',
- value: pulumi.interpolate`${FUSIONAUTH_CLIENT_ID}`,
- },
- {
- name: 'CONNECTION_GATEWAY_URL',
- value: pulumi.interpolate`${connectionGatewayEndpoint}`,
- },
- {
- name: 'NOTIFICATION_QUEUE',
- value: pulumi.interpolate`${notificationQueueName}`,
- },
- {
- name: 'CONTACTS_QUEUE',
- value: pulumi.interpolate`${contactsQueueName}`,
- },
- {
- name: 'AUTHENTICATION_SERVICE_SECRET_KEY',
- value: pulumi.interpolate`${AUTHENTICATION_SERVICE_SECRET_KEY}`,
- },
- {
- name: 'AUTHENTICATION_SERVICE_URL',
- value: `https://auth-service${stack === 'prod' ? '' : `-${stack}`}.macro.com`,
- },
- {
- name: 'DOCUMENT_PERMISSION_JWT_SECRET_KEY',
- value: pulumi.interpolate`${DOCUMENT_STORAGE_PERMISSIONS_KEY}`,
- },
- {
- name: 'SEARCH_EVENT_QUEUE',
- value: pulumi.interpolate`${searchEventQueueName}`,
- },
- {
- 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: 'MACRO_DB_URL',
- value: pulumi.interpolate`${MACRO_DB_URL_SECRET_NAME}`,
- },
- ],
- isPrivate: false,
- tags,
- secretKeyArns,
-});
-
-export const commsServiceSgId = commsService.serviceSg.id;
-export const commsServiceAlbSgId = commsService.serviceAlbSg.id;
-export const commsServiceUrl = pulumi.interpolate`${commsService.domain}`;
diff --git a/infra/stacks/comms-service/package.json b/infra/stacks/comms-service/package.json
deleted file mode 100644
index 563a9a8ec8..0000000000
--- a/infra/stacks/comms-service/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "comms-service-stack",
- "version": "0.0.0",
- "private": true,
- "license": "MIT"
-}
diff --git a/infra/stacks/comms-service/tsconfig.json b/infra/stacks/comms-service/tsconfig.json
deleted file mode 100644
index 6f83eb665f..0000000000
--- a/infra/stacks/comms-service/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": "../../tsconfig.json",
-}
diff --git a/infra/stacks/search-service/Pulumi.dev.yaml b/infra/stacks/search-service/Pulumi.dev.yaml
deleted file mode 100644
index 2bf5351b3a..0000000000
--- a/infra/stacks/search-service/Pulumi.dev.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-config:
- aws:region: us-east-1
- search-service:macro_db_secret_key: macro-db-dev
- search-service:opensearch_password_key: macro-opensearch-password-dev
- search-service:internal_auth_key: document-storage-service-auth-key-dev
- search-service:fusionauth_client_id: fusionauth-client-id-key-dev
- search-service:fusionauth_issuer: fusionauth-dev.macro.com
- search-service:jwt_secret_key: fusionauth-jwt-secret-dev
diff --git a/infra/stacks/search-service/Pulumi.prod.yaml b/infra/stacks/search-service/Pulumi.prod.yaml
deleted file mode 100644
index c85fcb4bf0..0000000000
--- a/infra/stacks/search-service/Pulumi.prod.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-config:
- aws:region: us-east-1
- search-service:macro_db_secret_key: macro-db-prod
- search-service:opensearch_password_key: macro-opensearch-password-prod
- search-service:internal_auth_key: document-storage-service-auth-key-prod
- search-service:fusionauth_client_id: fusionauth-client-id-key-prod
- search-service:fusionauth_issuer: auth.macro.com
- search-service:jwt_secret_key: fusionauth-jwt-secret-prod
diff --git a/infra/stacks/search-service/Pulumi.yaml b/infra/stacks/search-service/Pulumi.yaml
deleted file mode 100644
index 17022701e6..0000000000
--- a/infra/stacks/search-service/Pulumi.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-name: search-service
-runtime: nodejs
-description: Search Service
diff --git a/infra/stacks/search-service/index.ts b/infra/stacks/search-service/index.ts
deleted file mode 100644
index d017b6d110..0000000000
--- a/infra/stacks/search-service/index.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-import * as aws from '@pulumi/aws';
-import * as pulumi from '@pulumi/pulumi';
-import { config, getMacroApiToken, stack } from '../../packages/shared';
-import { get_coparse_api_vpc } from '../../packages/vpc';
-import { SearchService } from './service';
-
-const tags = {
- environment: stack,
- tech_lead: 'hutch',
- project: 'cloud-storage-search',
-};
-
-const vpc = get_coparse_api_vpc();
-
-const cloudStorageStack = new pulumi.StackReference('cloud-storage-stack', {
- name: `macro-inc/document-storage/${stack}`,
-});
-
-const cloudStorageClusterArn: pulumi.Output<string> = cloudStorageStack
- .getOutput('cloudStorageClusterArn')
- .apply((arn) => arn as string);
-
-const cloudStorageClusterName: pulumi.Output<string> = cloudStorageStack
- .getOutput('cloudStorageClusterName')
- .apply((arn) => arn as string);
-
-const opensearchStack = new pulumi.StackReference('opensearch-stack', {
- name: `macro-inc/opensearch/${stack}`,
-});
-
-const OPENSEARCH_URL: pulumi.Output<string> = opensearchStack
- .getOutput('domainEndpoint')
- .apply((domainEndpoint) => `https://${domainEndpoint}`);
-
-const OPENSEARCH_USERNAME = 'macrouser';
-const OPENSEARCH_PASSWORD = config.require('opensearch_password_key');
-const opensearchPasswordArn = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: OPENSEARCH_PASSWORD,
- })
- .apply((secret) => secret.arn);
-
-const BASE_NAME = 'search-service';
-
-const DATABASE_URL = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require(`macro_db_secret_key`),
- })
- .apply((secret) => secret.secretString);
-
-const INTERNAL_AUTH_KEY = aws.secretsmanager
- .getSecretVersionOutput({
- secretId: config.require(`internal_auth_key`),
- })
- .apply((secret) => secret.secretString);
-
-const JWT_SECRET_KEY = config.require(`jwt_secret_key`);
-const jwtSecretKeyArn: pulumi.Output<string> = aws.secretsmanager
- .getSecretVersionOutput({ secretId: JWT_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 MACRO_API_TOKENS = getMacroApiToken();
-
-const searchService = new SearchService(`${BASE_NAME}-${stack}`, {
- secretKeyArns: [
- opensearchPasswordArn,
- jwtSecretKeyArn,
- MACRO_API_TOKENS.macroApiTokenPublicKeyArn,
- ],
- ecsClusterArn: cloudStorageClusterArn,
- clusterName: cloudStorageClusterName,
- vpc,
- platform: { family: 'linux', architecture: 'amd64' },
- serviceContainerPort: 8080,
- isPrivate: false,
- healthCheckPath: '/health',
- containerEnvVars: [
- { name: 'ENVIRONMENT', value: stack },
- {
- name: 'RUST_LOG',
- value: `search_service=${
- stack === 'prod' ? 'info' : 'trace'
- },macro_db_client=info,opensearch_client=error`,
- },
- {
- name: 'DATABASE_URL',
- value: pulumi.interpolate`${DATABASE_URL}`,
- },
- {
- name: 'OPENSEARCH_URL',
- value: OPENSEARCH_URL,
- },
- {
- name: 'OPENSEARCH_USERNAME',
- value: OPENSEARCH_USERNAME,
- },
- {
- name: 'OPENSEARCH_PASSWORD',
- value: OPENSEARCH_PASSWORD,
- },
- {
- name: 'INTERNAL_API_SECRET_KEY',
- value: INTERNAL_AUTH_KEY,
- },
- {
- name: 'JWT_SECRET_KEY',
- value: pulumi.interpolate`${JWT_SECRET_KEY}`,
- },
- {
- name: 'AUDIENCE',
- value: pulumi.interpolate`${AUDIENCE}`,
- },
- {
- name: 'ISSUER',
- value: pulumi.interpolate`${ISSUER}`,
- },
- {
- name: 'EMAIL_SERVICE_URL',
- value: `https://email-service${
- stack === 'prod' ? '' : `-${stack}`
- }.macro.com`,
- },
- {
- name: 'DOCUMENT_STORAGE_SERVICE_URL',
- value: `https://cloud-storage${
- stack === 'prod' ? '' : `-${stack}`
- }.macro.com`,
- },
- {
- 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}`,
- },
- ],
- tags,
-});
-
-export const searchServiceUrl = pulumi.interpolate`${searchService.domain}`;
-export const searchServiceRoleArn = searchService.role.arn;
diff --git a/infra/stacks/search-service/package.json b/infra/stacks/search-service/package.json
deleted file mode 100644
index 35693540dd..0000000000
--- a/infra/stacks/search-service/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "search-service-stack",
- "version": "0.0.0",
- "private": true,
- "license": "MIT",
- "main": "index.ts"
-}
diff --git a/infra/stacks/search-service/service.ts b/infra/stacks/search-service/service.ts
deleted file mode 100644
index 9898ea2e6b..0000000000
--- a/infra/stacks/search-service/service.ts
+++ /dev/null
@@ -1,487 +0,0 @@
-import * as aws from '@pulumi/aws';
-import * as awsx from '@pulumi/awsx';
-import * as pulumi from '@pulumi/pulumi';
-import {
- DATADOG_API_KEY,
- datadogAgentContainer,
- fargateLogRouterSidecarContainer,
- serviceLoadBalancer,
-} from '../../packages/resources';
-import { EcrImage } from '../../packages/service';
-import {
- BASE_DOMAIN,
- CLOUD_TRAIL_SNS_TOPIC_ARN,
- stack,
-} from '../../packages/shared';
-
-const BASE_NAME = 'search-service';
-const BASE_PATH = '../../../rust/cloud-storage';
-
-export const SERVICE_DOMAIN_NAME = `search-service${
- stack === 'prod' ? '' : `-${stack}`
-}.${BASE_DOMAIN}`;
-
-type Args = {
- secretKeyArns: (pulumi.Output<string> | string)[];
- clusterName: pulumi.Output<string> | string;
- ecsClusterArn: pulumi.Output<string> | string;
- vpc: {
- vpcId: pulumi.Output<string> | string;
- publicSubnetIds: pulumi.Output<string[]> | string[];
- privateSubnetIds: pulumi.Output<string[]> | string[];
- };
- platform: { family: string; architecture: 'amd64' | 'arm64' };
- serviceContainerPort: number;
- isPrivate?: boolean;
- containerEnvVars?: { name: string; value: pulumi.Output<string> | string }[];
- healthCheckPath: string;
- tags: { [key: string]: string };
-};
-
-export class SearchService extends pulumi.ComponentResource {
- public role: aws.iam.Role;
- public ecr: awsx.ecr.Repository;
- public serviceAlbSg: aws.ec2.SecurityGroup;
- public serviceSg: aws.ec2.SecurityGroup;
- public targetGroup: aws.lb.TargetGroup;
- public lb: aws.lb.LoadBalancer;
- public listener: aws.lb.Listener;
- public service: awsx.ecs.FargateService;
- public domain: string;
- public clusterName: pulumi.Output<string> | string;
- public tags: { [key: string]: string };
-
- constructor(
- name: string,
- {
- ecsClusterArn,
- vpc,
- platform,
- serviceContainerPort,
- healthCheckPath,
- isPrivate,
- containerEnvVars,
- clusterName,
- tags,
- secretKeyArns,
- }: Args,
- opts?: pulumi.ComponentResourceOptions
- ) {
- super('my:components:Service', name, {}, opts);
- this.tags = tags;
-
- this.clusterName = clusterName;
-
- // role
- const secretsPolicy = new aws.iam.Policy(
- `${BASE_NAME}-secrets-policy`,
- {
- policy: {
- Version: '2012-10-17',
- Statement: [
- {
- Action: ['secretsmanager:GetSecretValue'],
- Resource: [...secretKeyArns],
- Effect: 'Allow',
- },
- ],
- },
- tags: this.tags,
- },
- { parent: this }
- );
-
- this.role = new aws.iam.Role(
- `${BASE_NAME}-role`,
- {
- name: `${BASE_NAME}-role-${stack}`,
- assumeRolePolicy: {
- Version: '2012-10-17',
- Statement: [
- {
- Action: 'sts:AssumeRole',
- Principal: {
- Service: 'ecs-tasks.amazonaws.com',
- },
- Effect: 'Allow',
- Sid: '',
- },
- ],
- },
- tags: this.tags,
- managedPolicyArns: [secretsPolicy.arn],
- },
- { parent: this }
- );
-
- // ecr image
- const image = new EcrImage(
- `${BASE_NAME}-ecr-image-${stack}`,
- {
- repositoryId: `${BASE_NAME}-ecr-${stack}`,
- repositoryName: `${BASE_NAME}-${stack}`,
- imageId: `${BASE_NAME}-image-${stack}`,
- imagePath: BASE_PATH,
- dockerfile: 'Dockerfile',
- buildArgs: {
- SERVICE_NAME: 'search_service',
- },
- platform,
- tags: this.tags,
- },
- { parent: this }
- );
- this.ecr = image.ecr;
-
- // sg
- const sg = this.initializeSecurityGroups({
- vpcId: vpc.vpcId,
- serviceContainerPort,
- });
- this.serviceAlbSg = sg.serviceAlbSg;
- this.serviceSg = sg.serviceSg;
-
- // lb
- const { targetGroup, lb, listener } = serviceLoadBalancer(this, {
- serviceName: BASE_NAME, // service name
- serviceContainerPort,
- healthCheckPath,
- vpc,
- albSecurityGroupId: this.serviceAlbSg.id,
- isPrivate,
- tags,
- });
- this.targetGroup = targetGroup;
- this.lb = lb;
- this.listener = listener;
-
- // service
- const service = new awsx.ecs.FargateService(
- `${BASE_NAME}`,
- {
- tags,
- cluster: ecsClusterArn,
- networkConfiguration: {
- subnets: vpc.privateSubnetIds,
- securityGroups: [this.serviceSg.id],
- },
- taskDefinitionArgs: {
- taskRole: {
- roleArn: this.role.arn,
- },
- containers: {
- log_router: fargateLogRouterSidecarContainer,
- datadog_agent: datadogAgentContainer,
- service: {
- name: BASE_NAME,
- image: image.image.imageUri,
- stopTimeout: 10, // 10 seconds to force kill the task
- cpu: stack === 'prod' ? 512 : 256,
- memory: stack === 'prod' ? 1024 : 512,
- environment: containerEnvVars ?? [],
- logConfiguration: {
- logDriver: 'awsfirelens',
- options: {
- Name: 'datadog',
- Host: 'http-intake.logs.us5.datadoghq.com',
- apikey: DATADOG_API_KEY,
- dd_service: `search-service-${stack}`,
- dd_source: 'fargate',
- dd_tags: `project:cloudstorage, env:${stack}`,
- provider: 'ecs',
- },
- },
- portMappings: [
- {
- appProtocol: 'http',
- name: `${BASE_NAME}-tcp-${stack}`,
- hostPort: serviceContainerPort,
- containerPort: serviceContainerPort,
- targetGroup,
- },
- ],
- },
- },
- runtimePlatform: {
- operatingSystemFamily: `${platform.family.toUpperCase()}`,
- cpuArchitecture: `${
- platform.architecture === 'amd64'
- ? 'X86_64'
- : platform.architecture.toUpperCase()
- }`,
- },
- },
- desiredCount: stack === 'prod' ? 3 : 1,
- },
- { parent: this }
- );
-
- this.service = service;
-
- this.setupAutoScaling();
-
- this.setupServiceAlarms();
-
- // domain record
- const zone = aws.route53.getZoneOutput({ name: BASE_DOMAIN });
-
- new aws.route53.Record(
- `${BASE_NAME}-domain-record`,
- {
- name: SERVICE_DOMAIN_NAME,
- type: 'A',
- zoneId: zone.zoneId,
- aliases: [
- {
- evaluateTargetHealth: false,
- name: this.lb.dnsName,
- zoneId: this.lb.zoneId,
- },
- ],
- },
- { parent: this }
- );
-
- this.domain = `https://${SERVICE_DOMAIN_NAME}`;
- }
-
- initializeSecurityGroups({
- vpcId,
- serviceContainerPort,
- }: {
- vpcId: pulumi.Output<string> | string;
- serviceContainerPort: number;
- }) {
- const serviceAlbSg = new aws.ec2.SecurityGroup(
- `${BASE_NAME}-alb-sg-${stack}`,
- {
- name: `${BASE_NAME}-alb-sg-${stack}`,
- description: `${BASE_NAME} application load balancer security group`,
- vpcId,
- tags: this.tags,
- },
- { parent: this }
- );
-
- const serviceSg = new aws.ec2.SecurityGroup(
- `${BASE_NAME}-sg-${stack}`,
- {
- name: `${BASE_NAME}-sg-${stack}`,
- vpcId,
- description: `${BASE_NAME} security group that is attached directly to the service`,
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.vpc.SecurityGroupIngressRule(
- `${BASE_NAME}-alb-in`,
- {
- securityGroupId: serviceSg.id,
- description: 'Allow inbound traffic from the services ALB',
- referencedSecurityGroupId: serviceAlbSg.id,
- fromPort: serviceContainerPort,
- toPort: serviceContainerPort,
- ipProtocol: 'tcp',
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.vpc.SecurityGroupEgressRule(
- `${BASE_NAME}-all-out`,
- {
- securityGroupId: serviceSg.id,
- description: 'Allow all outbound',
- cidrIpv4: '0.0.0.0/0',
- ipProtocol: '-1',
- tags: this.tags,
- },
- { parent: this }
- );
-
- // ALB SG rules
- new aws.vpc.SecurityGroupIngressRule(
- `${BASE_NAME}-http`,
- {
- securityGroupId: serviceAlbSg.id,
- description: 'Allow inbound HTTP traffic',
- cidrIpv4: '0.0.0.0/0',
- fromPort: 80,
- ipProtocol: 'tcp',
- toPort: 80,
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.vpc.SecurityGroupIngressRule(
- `${BASE_NAME}-https`,
- {
- securityGroupId: serviceAlbSg.id,
- description: 'Allow inbound HTTPS traffic',
- cidrIpv4: '0.0.0.0/0',
- fromPort: 443,
- ipProtocol: 'tcp',
- toPort: 443,
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.vpc.SecurityGroupEgressRule(
- `${BASE_NAME}-out-service`,
- {
- description: 'Allow traffic to the service security group',
- securityGroupId: serviceAlbSg.id,
- referencedSecurityGroupId: serviceSg.id,
- fromPort: serviceContainerPort,
- ipProtocol: 'tcp',
- toPort: serviceContainerPort,
- tags: this.tags,
- },
- { parent: this }
- );
-
- return { serviceAlbSg, serviceSg };
- }
-
- setupAutoScaling() {
- if (!this.service) return;
-
- const serviceScalableTarget = new aws.appautoscaling.Target(
- `${BASE_NAME}-service-scalable-target-${stack}`,
- {
- maxCapacity: stack === 'prod' ? 10 : 3,
- minCapacity: stack === 'prod' ? 3 : 1,
- resourceId: pulumi.interpolate`service/${this.clusterName}/${this.service.service.name}`,
- scalableDimension: 'ecs:service:DesiredCount',
- serviceNamespace: 'ecs',
- tags: this.tags,
- },
- { parent: this }
- );
-
- const lbPortion: pulumi.Output<string> = this.lb.arn.apply((arn) => {
- const parts = arn.split(':loadbalancer/');
- return parts[1];
- });
-
- const tgPortion: pulumi.Output<string> = this.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(
- `${BASE_NAME}-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: 60,
- scaleOutCooldown: 120,
- },
- },
- { parent: this }
- );
-
- // Create an Auto Scaling policy for CPU utilization.
- new aws.appautoscaling.Policy(
- `${BASE_NAME}-scaling-policy-cpu-${stack}`,
- {
- policyType: 'TargetTrackingScaling',
- resourceId: serviceScalableTarget.resourceId,
- scalableDimension: serviceScalableTarget.scalableDimension,
- serviceNamespace: serviceScalableTarget.serviceNamespace,
- targetTrackingScalingPolicyConfiguration: {
- targetValue: 60.0,
- predefinedMetricSpecification: {
- predefinedMetricType: 'ECSServiceAverageCPUUtilization',
- },
- scaleInCooldown: 100,
- scaleOutCooldown: 300,
- },
- },
- { parent: this }
- );
-
- new aws.appautoscaling.Policy(
- `${BASE_NAME}-scaling-policy-memory-${stack}`,
- {
- policyType: 'TargetTrackingScaling',
- resourceId: serviceScalableTarget.resourceId,
- scalableDimension: serviceScalableTarget.scalableDimension,
- serviceNamespace: serviceScalableTarget.serviceNamespace,
- targetTrackingScalingPolicyConfiguration: {
- targetValue: 60.0,
- predefinedMetricSpecification: {
- predefinedMetricType: 'ECSServiceAverageMemoryUtilization',
- },
- scaleInCooldown: 100,
- scaleOutCooldown: 300,
- },
- },
- { parent: this }
- );
- }
-
- setupServiceAlarms() {
- new aws.cloudwatch.MetricAlarm(
- `${BASE_NAME}-high-cpu-alarm`,
- {
- name: `${BASE_NAME}-high-cpu-alarm-${stack}`,
- metricName: 'CPUUtilization',
- namespace: 'AWS/ECS',
- statistic: 'Average',
- period: 180,
- evaluationPeriods: 1,
- threshold: 80,
- comparisonOperator: 'GreaterThanThreshold',
- dimensions: {
- ClusterName: this.clusterName,
- ServiceName: this.service.service.name,
- },
- alarmDescription: `High CPU usage alarm for ${BASE_NAME} service.`,
- actionsEnabled: true,
- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],
- tags: this.tags,
- },
- { parent: this }
- );
-
- new aws.cloudwatch.MetricAlarm(
- `${BASE_NAME}-high-mem-alarm`,
- {
- name: `${BASE_NAME}-high-mem-alarm-${stack}`,
- metricName: 'MemoryUtilization',
- namespace: 'AWS/ECS',
- statistic: 'Average',
- period: 180,
- evaluationPeriods: 1,
- threshold: 80,
- comparisonOperator: 'GreaterThanThreshold',
- dimensions: {
- ClusterName: this.clusterName,
- ServiceName: this.service.service.name,
- },
- alarmDescription: `High Memory usage alarm for ${BASE_NAME} service.`,
- actionsEnabled: true,
- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],
- tags: this.tags,
- },
- { parent: this }
- );
- }
-}
diff --git a/infra/stacks/search-service/tsconfig.json b/infra/stacks/search-service/tsconfig.json
deleted file mode 100644
index 4082f16a5d..0000000000
--- a/infra/stacks/search-service/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": "../../tsconfig.json"
-}