Skip to content

Commit

Permalink
fix(batch): computeEnvironments is now required for JobQueue (#6616)
Browse files Browse the repository at this point in the history
Fixes: #6615

BREAKING CHANGE: `computeEnvironments` is now required
  • Loading branch information
andrestone authored and Elad Ben-Israel committed Mar 9, 2020
1 parent 310e025 commit 8f56b43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
25 changes: 10 additions & 15 deletions packages/@aws-cdk/aws-batch/lib/job-queue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Construct, IResource, Resource, Stack } from '@aws-cdk/core';
import { CfnJobQueue } from './batch.generated';
import { ComputeEnvironment, IComputeEnvironment } from './compute-environment';
import { IComputeEnvironment } from './compute-environment';

/**
* Properties for mapping a compute environment to a job queue.
Expand All @@ -26,7 +26,7 @@ export interface JobQueueProps {
*
* Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.
*
* @default Cloudformation-generated name
* @default - Cloudformation-generated name
*/
readonly jobQueueName?: string;

Expand All @@ -35,9 +35,8 @@ export interface JobQueueProps {
* determine which compute environment should execute a given job. Compute environments must be in the VALID state before you can associate them
* with a job queue. You can associate up to three compute environments with a job queue.
*
* @default Default-Compute-Environment
*/
readonly computeEnvironments?: JobQueueComputeEnvironment[];
readonly computeEnvironments: JobQueueComputeEnvironment[];

/**
* The priority of the job queue. Job queues with a higher priority (or a higher integer value for the priority parameter) are evaluated first
Expand Down Expand Up @@ -106,24 +105,20 @@ export class JobQueue extends Resource implements IJobQueue {
public readonly jobQueueArn: string;
public readonly jobQueueName: string;

constructor(scope: Construct, id: string, props: JobQueueProps = {}) {
constructor(scope: Construct, id: string, props: JobQueueProps) {
super(scope, id, {
physicalName: props.jobQueueName,
});

if (props.computeEnvironments.length === 0) {
throw new Error('computeEnvironments must be non-empty');
}

const jobQueue = new CfnJobQueue(this, 'Resource', {
computeEnvironmentOrder: props.computeEnvironments
? props.computeEnvironments.map(cp => ({
computeEnvironmentOrder: props.computeEnvironments.map(cp => ({
computeEnvironment: cp.computeEnvironment.computeEnvironmentArn,
order: cp.order,
} as CfnJobQueue.ComputeEnvironmentOrderProperty))
: [
{
// Get an AWS Managed Compute Environment
computeEnvironment: new ComputeEnvironment(this, 'Resource-Batch-Compute-Environment').computeEnvironmentArn,
order: 1,
},
],
} as CfnJobQueue.ComputeEnvironmentOrderProperty)),
jobQueueName: this.physicalName,
priority: props.priority || 1,
state: props.enabled === undefined ? 'ENABLED' : (props.enabled ? 'ENABLED' : 'DISABLED'),
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-batch/test/job-queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Batch Job Queue', () => {
expect(jobQFromArn.jobQueueArn).toEqual(existingJobQ.jobQueueArn);
});

it('renders the correct cloudformation properties', () => {
it('renders the correct CloudFormation properties', () => {
// WHEN
const props: batch.JobQueueProps = {
priority: 1,
Expand Down

0 comments on commit 8f56b43

Please sign in to comment.