diff --git a/packages/@aws-cdk/aws-glue-alpha/lib/job.ts b/packages/@aws-cdk/aws-glue-alpha/lib/job.ts index 813894f0b6898..d9ae42d3bbd94 100644 --- a/packages/@aws-cdk/aws-glue-alpha/lib/job.ts +++ b/packages/@aws-cdk/aws-glue-alpha/lib/job.ts @@ -743,6 +743,14 @@ export class Job extends JobBase { throw new Error('Both workerType and workerCount must be set'); } + if (executable.type === JobType.RAY && props.timeout) { + throw new Error('Ray jobs do not support timeout'); + } + + if (executable.type === JobType.RAY && (props.workerType !== WorkerType.Z_2X)) { + throw new Error('Ray jobs must specify workerType, which may only be Z_2X'); + } + const jobResource = new CfnJob(this, 'Resource', { name: props.jobName, description: props.description, diff --git a/packages/@aws-cdk/aws-glue-alpha/test/job.test.ts b/packages/@aws-cdk/aws-glue-alpha/test/job.test.ts index 0e6db582c1d71..53c4b523c3bd5 100644 --- a/packages/@aws-cdk/aws-glue-alpha/test/job.test.ts +++ b/packages/@aws-cdk/aws-glue-alpha/test/job.test.ts @@ -874,6 +874,44 @@ describe('Job', () => { workerCount: 2, })).toThrow('Runtime is required for Ray jobs'); }); + + test('with timeout should throw', () => { + expect(() => new glue.Job(stack, 'Job', { + executable: glue.JobExecutable.pythonRay({ + glueVersion: glue.GlueVersion.V4_0, + pythonVersion: glue.PythonVersion.THREE_NINE, + runtime: glue.Runtime.RAY_TWO_FOUR, + script, + }), + workerType: glue.WorkerType.Z_2X, + workerCount: 2, + timeout: cdk.Duration.minutes(5), + })).toThrow('Ray jobs do not support timeout'); + }); + + test('without worker type should throw', () => { + expect(() => new glue.Job(stack, 'Job', { + executable: glue.JobExecutable.pythonRay({ + glueVersion: glue.GlueVersion.V4_0, + pythonVersion: glue.PythonVersion.THREE_NINE, + runtime: glue.Runtime.RAY_TWO_FOUR, + script, + }), + })).toThrow('Ray jobs must specify workerType, which may only be Z_2X'); + }); + + test('with unsupported worker type should throw', () => { + expect(() => new glue.Job(stack, 'Job', { + executable: glue.JobExecutable.pythonRay({ + glueVersion: glue.GlueVersion.V4_0, + pythonVersion: glue.PythonVersion.THREE_NINE, + runtime: glue.Runtime.RAY_TWO_FOUR, + script, + }), + workerType: glue.WorkerType.G_1X, + workerCount: 2, + })).toThrow('Ray jobs must specify workerType, which may only be Z_2X'); + }); }); test('etl job with all props should synthesize correctly', () => {