Skip to content

Commit

Permalink
fix(deadline): VersionQuery cross-stack issue (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlove-aws committed Feb 17, 2021
1 parent 12b6d89 commit e6bb60d
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 36 deletions.
26 changes: 26 additions & 0 deletions packages/aws-rfdk/lib/deadline/lib/render-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ import {
import {
Construct,
IConstruct,
Stack,
} from '@aws-cdk/core';

import {
ECSConnectOptions,
InstanceConnectOptions,
IRepository,
IVersion,
RenderQueueProps,
VersionQuery,
} from '.';

import {
Expand Down Expand Up @@ -232,6 +235,11 @@ export class RenderQueue extends RenderQueueBase implements IGrantable {
*/
private readonly taskDefinition: Ec2TaskDefinition;

/**
* The version of Deadline installed in the container images
*/
private readonly version?: IVersion;

constructor(scope: Construct, id: string, props: RenderQueueProps) {
super(scope, id);

Expand All @@ -243,6 +251,8 @@ export class RenderQueue extends RenderQueueBase implements IGrantable {
throw new Error(`renderQueueSize.desired cannot be greater than 1 - got ${props.renderQueueSize.desired}`);
}

this.version = props?.version;

let externalProtocol: ApplicationProtocol;
if ( props.trafficEncryption?.externalTLS ) {
externalProtocol = ApplicationProtocol.HTTPS;
Expand Down Expand Up @@ -444,6 +454,22 @@ export class RenderQueue extends RenderQueueBase implements IGrantable {
tagConstruct(this);
}

protected onValidate(): string[] {
const validationErrors = [];

// Using the output of VersionQuery across stacks can cause issues. CloudFormation stack outputs cannot change if
// a resource in another stack is referencing it.
if (this.version instanceof VersionQuery) {
const versionStack = Stack.of(this.version);
const thisStack = Stack.of(this);
if (versionStack != thisStack) {
validationErrors.push('A VersionQuery can not be supplied from a different stack');
}
}

return validationErrors;
}

/**
* @inheritdoc
*/
Expand Down
17 changes: 17 additions & 0 deletions packages/aws-rfdk/lib/deadline/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import {

import { DatabaseConnection } from './database-connection';
import { IHost } from './host-ref';
import { VersionQuery } from './version-query';
import { IVersion } from './version-ref';

/**
Expand Down Expand Up @@ -585,6 +586,22 @@ export class Repository extends Construct implements IRepository {
tagConstruct(this);
}

protected onValidate(): string[] {
const validationErrors = [];

// Using the output of VersionQuery across stacks can cause issues. CloudFormation stack outputs cannot change if
// a resource in another stack is referencing it.
if (this.version instanceof VersionQuery) {
const versionStack = Stack.of(this.version);
const thisStack = Stack.of(this);
if (versionStack != thisStack) {
validationErrors.push('A VersionQuery can not be supplied from a different stack');
}
}

return validationErrors;
}

/**
* @inheritdoc
*/
Expand Down
11 changes: 11 additions & 0 deletions packages/aws-rfdk/lib/deadline/lib/thinkbox-docker-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
Construct,
CustomResource,
Duration,
Stack,
Token,
} from '@aws-cdk/core';

Expand All @@ -28,6 +29,7 @@ import {
RenderQueueImages,
ThinkboxManagedDeadlineDockerRecipes,
UsageBasedLicensingImages,
VersionQuery,
} from '.';

/**
Expand Down Expand Up @@ -225,6 +227,15 @@ AWS Thinkbox EULA.
errors.push(ThinkboxDockerImages.AWS_THINKBOX_EULA_MESSAGE);
}

// Using the output of VersionQuery across stacks can cause issues. CloudFormation stack outputs cannot change if
// a resource in another stack is referencing it.
if (this.version instanceof VersionQuery) {
const versionStack = Stack.of(this.version);
const thisStack = Stack.of(this);
if (versionStack != thisStack) {
errors.push('A VersionQuery can not be supplied from a different stack');
}
}
return errors;
}

Expand Down
Loading

0 comments on commit e6bb60d

Please sign in to comment.