From b14a005767832beb9bcb4d7d39ea5630d202c566 Mon Sep 17 00:00:00 2001 From: anabellabuckvar <41971124+anabellabuckvar@users.noreply.github.com> Date: Tue, 9 Apr 2024 18:07:01 -0400 Subject: [PATCH] DOP-4451 filling out initial TODOs --- cdk-infra/lib/constructs/worker/worker-construct.ts | 3 +++ cdk-infra/lib/stacks/webhook-stack.ts | 6 ++++++ cdk-infra/lib/stacks/worker-stack.ts | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cdk-infra/lib/constructs/worker/worker-construct.ts b/cdk-infra/lib/constructs/worker/worker-construct.ts index 63f550305..b24e8baa6 100644 --- a/cdk-infra/lib/constructs/worker/worker-construct.ts +++ b/cdk-infra/lib/constructs/worker/worker-construct.ts @@ -6,6 +6,7 @@ import { FargateService, FargateTaskDefinition, LogDrivers, + TaskDefinition, } from 'aws-cdk-lib/aws-ecs'; import { Effect, IRole, PolicyStatement, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam'; import { LogGroup } from 'aws-cdk-lib/aws-logs'; @@ -23,6 +24,7 @@ interface WorkerConstructProps { export class WorkerConstruct extends Construct { readonly ecsTaskRole: IRole; readonly clusterName: string; + readonly taskDefinition: TaskDefinition; constructor( scope: Construct, @@ -112,6 +114,7 @@ export class WorkerConstruct extends Construct { maxHealthyPercent: 200, }); + this.taskDefinition = taskDefinition; this.clusterName = cluster.clusterName; this.ecsTaskRole = taskRole; } diff --git a/cdk-infra/lib/stacks/webhook-stack.ts b/cdk-infra/lib/stacks/webhook-stack.ts index 41367a41b..89d4b163a 100644 --- a/cdk-infra/lib/stacks/webhook-stack.ts +++ b/cdk-infra/lib/stacks/webhook-stack.ts @@ -1,5 +1,7 @@ import { Stack, StackProps } from 'aws-cdk-lib'; import { Construct } from 'constructs'; +import { Vpc } from 'aws-cdk-lib/aws-ec2'; +import { TaskDefinition } from 'aws-cdk-lib/aws-ecs'; import { AutoBuilderQueues } from './auto-builder-queue-stack'; import { WebhookApiConstruct } from '../constructs/api/webhook-api-construct'; import { WebhookEnvConstruct } from '../constructs/api/webhook-env-construct'; @@ -8,7 +10,11 @@ interface WebhookStackProps extends StackProps { webhookSecureStrings: Record; queues: AutoBuilderQueues; clusterName: string; + vpc: Vpc; + taskDefinition: TaskDefinition; } + +//TODO: use taskDefition and vpc somewhere here export class WebhookStack extends Stack { constructor( scope: Construct, diff --git a/cdk-infra/lib/stacks/worker-stack.ts b/cdk-infra/lib/stacks/worker-stack.ts index 79ccddd2b..1cb605d61 100644 --- a/cdk-infra/lib/stacks/worker-stack.ts +++ b/cdk-infra/lib/stacks/worker-stack.ts @@ -4,6 +4,7 @@ import { WorkerConstruct } from '../constructs/worker/worker-construct'; import { WorkerEnvConstruct } from '../constructs/worker/worker-env-construct'; import { WorkerBucketsConstruct } from '../constructs/worker/buckets-construct'; import { AutoBuilderQueues } from './auto-builder-queue-stack'; +import { TaskDefinition } from 'aws-cdk-lib/aws-ecs'; import { IVpc } from 'aws-cdk-lib/aws-ec2'; interface WorkerStackProps extends StackProps { @@ -16,6 +17,7 @@ export class WorkerStack extends Stack { // TODO: Create the task definition as properties here so // that they are accessible to the webhook stack public readonly clusterName: string; + public readonly taskDefinition: TaskDefinition; constructor(scope: Construct, id: string, { queues, workerSecureStrings, vpc, ...props }: WorkerStackProps) { super(scope, id, props); @@ -27,7 +29,7 @@ export class WorkerStack extends Stack { // TODO: retrieve the task definition from this stack as it is required // for the RunTask in the smoke test build - const { clusterName, ecsTaskRole } = new WorkerConstruct(this, 'worker', { + const { clusterName, ecsTaskRole, taskDefinition } = new WorkerConstruct(this, 'worker', { vpc, dockerEnvironment: environment, ...queues, @@ -40,6 +42,7 @@ export class WorkerStack extends Stack { // TODO: Assign the task definition as properties here so // that they are accessible to the webhook stack + this.taskDefinition = taskDefinition; this.clusterName = clusterName; } }