From 611f0d8059aec5f29f3806e944fd3222e60996bc Mon Sep 17 00:00:00 2001 From: Guy Hawkins <2242982+ghawk1ns@users.noreply.github.com> Date: Wed, 27 Oct 2021 09:52:51 -0700 Subject: [PATCH] fix: Pass engine endpoint directly the wes adapter (#122) --- .../cdk/lib/env/context-app-parameters.ts | 3 ++- .../stacks/nested/cromwell-engine-stack.ts | 24 +++++++------------ packages/cdk/lib/util/index.ts | 4 +--- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/packages/cdk/lib/env/context-app-parameters.ts b/packages/cdk/lib/env/context-app-parameters.ts index 1cfd179e..d3fd5e76 100644 --- a/packages/cdk/lib/env/context-app-parameters.ts +++ b/packages/cdk/lib/env/context-app-parameters.ts @@ -130,7 +130,7 @@ export class ContextAppParameters { }; } - public getAdapterContainer(): ServiceContainer { + public getAdapterContainer(additionalEnvVars?: { [key: string]: string }): ServiceContainer { return { serviceName: this.adapterName, imageConfig: { designation: this.adapterDesignation }, @@ -141,6 +141,7 @@ export class ContextAppParameters { CONTEXT_NAME: this.contextName, USER_ID: this.userId, ENGINE_NAME: this.engineName, + ...additionalEnvVars, }, }; } diff --git a/packages/cdk/lib/stacks/nested/cromwell-engine-stack.ts b/packages/cdk/lib/stacks/nested/cromwell-engine-stack.ts index 392a9e52..d7fa7659 100644 --- a/packages/cdk/lib/stacks/nested/cromwell-engine-stack.ts +++ b/packages/cdk/lib/stacks/nested/cromwell-engine-stack.ts @@ -1,12 +1,10 @@ import { NestedStackProps, RemovalPolicy } from "monocdk"; import { IVpc } from "monocdk/aws-ec2"; -import { CloudMapOptions, FargateTaskDefinition, LogDriver } from "monocdk/aws-ecs"; +import { FargateTaskDefinition, LogDriver } from "monocdk/aws-ecs"; import { Construct } from "constructs"; import { ApiProxy, SecureService } from "../../constructs"; -import { PrivateDnsNamespace } from "monocdk/aws-servicediscovery"; import { IRole } from "monocdk/aws-iam"; import { createEcrImage, renderServiceWithContainer, renderServiceWithTaskDefinition } from "../../util"; -import { APP_NAME } from "../../constants"; import { Bucket } from "monocdk/aws-s3"; import { FileSystem } from "monocdk/aws-efs"; import { EngineOptions, ServiceContainer } from "../../types"; @@ -23,6 +21,7 @@ export class CromwellEngineStack extends NestedEngineStack { public readonly adapter: SecureService; public readonly adapterRole: IRole; public readonly apiProxy: ApiProxy; + public readonly engineApiProxy: ApiProxy; public readonly adapterLogGroup: ILogGroup; public readonly engineLogGroup: ILogGroup; public readonly engineRole: IRole; @@ -45,19 +44,14 @@ export class CromwellEngineStack extends NestedEngineStack { readOnlyBucketArns: [], readWriteBucketArns: [outputBucket.bucketArn], }); - const namespace = new PrivateDnsNamespace(this, "EngineNamespace", { - name: `${params.projectName}-${params.contextName}-${params.userId}.${APP_NAME}.amazon.com`, - vpc: props.vpc, - }); - const cloudMapOptions: CloudMapOptions = { - name: engineContainer.serviceName, - cloudMapNamespace: namespace, - }; // TODO: Move log group creation into service construct and make it a property - this.engine = this.getEngineServiceDefinition(props.vpc, engineContainer, cloudMapOptions, this.engineLogGroup); + this.engine = this.getEngineServiceDefinition(props.vpc, engineContainer, this.engineLogGroup); this.adapterLogGroup = new LogGroup(this, "AdapterLogGroup"); - this.adapter = renderServiceWithContainer(this, "Adapter", params.getAdapterContainer(), props.vpc, this.adapterRole, this.adapterLogGroup); + const adapterContainer = params.getAdapterContainer({ + ENGINE_ENDPOINT: this.engine.loadBalancer.loadBalancerDnsName, + }); + this.adapter = renderServiceWithContainer(this, "Adapter", adapterContainer, props.vpc, this.adapterRole, this.adapterLogGroup); this.apiProxy = new ApiProxy(this, { apiName: `${params.projectName}${params.contextName}${engineContainer.serviceName}ApiProxy`, @@ -75,7 +69,7 @@ export class CromwellEngineStack extends NestedEngineStack { }; } - private getEngineServiceDefinition(vpc: IVpc, serviceContainer: ServiceContainer, cloudMapOptions: CloudMapOptions, logGroup: ILogGroup) { + private getEngineServiceDefinition(vpc: IVpc, serviceContainer: ServiceContainer, logGroup: ILogGroup) { const id = "Engine"; const fileSystem = new FileSystem(this, "EngineFileSystem", { vpc, @@ -112,7 +106,7 @@ export class CromwellEngineStack extends NestedEngineStack { sourceVolume: volumeName, }); - const engine = renderServiceWithTaskDefinition(this, id, serviceContainer, definition, vpc, cloudMapOptions); + const engine = renderServiceWithTaskDefinition(this, id, serviceContainer, definition, vpc); fileSystem.connections.allowDefaultPortFrom(engine.service); return engine; } diff --git a/packages/cdk/lib/util/index.ts b/packages/cdk/lib/util/index.ts index fadedb1d..5ce8d298 100644 --- a/packages/cdk/lib/util/index.ts +++ b/packages/cdk/lib/util/index.ts @@ -82,13 +82,11 @@ export const renderServiceWithTaskDefinition = ( id: string, serviceContainer: ServiceContainer, taskDefinition: TaskDefinition, - vpc: IVpc, - cloudMapOptions?: CloudMapOptions + vpc: IVpc ): SecureService => { return new SecureService(scope, id, { vpc, serviceName: serviceContainer.serviceName, - cloudMapOptions, taskDefinition: taskDefinition, healthCheck: { path: serviceContainer.healthCheckPath ?? defaultHealthCheckPath,