Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

fix: Pass engine endpoint directly to the wes adapter #122

Merged
merged 1 commit into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/cdk/lib/env/context-app-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -141,6 +141,7 @@ export class ContextAppParameters {
CONTEXT_NAME: this.contextName,
USER_ID: this.userId,
ENGINE_NAME: this.engineName,
...additionalEnvVars,
},
};
}
Expand Down
24 changes: 9 additions & 15 deletions packages/cdk/lib/stacks/nested/cromwell-engine-stack.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
Expand All @@ -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`,
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/cdk/lib/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down