Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(batch): computeEnvironments is now required for JobQueue #6616

Merged
merged 2 commits into from
Mar 9, 2020
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
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)),
andrestone marked this conversation as resolved.
Show resolved Hide resolved
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