diff --git a/packages/@aws-cdk/aws-glue-alpha/lib/job.ts b/packages/@aws-cdk/aws-glue-alpha/lib/job.ts index 6c6a1d5168f5d..d6f9a954861cd 100644 --- a/packages/@aws-cdk/aws-glue-alpha/lib/job.ts +++ b/packages/@aws-cdk/aws-glue-alpha/lib/job.ts @@ -738,6 +738,17 @@ export class Job extends JobBase { } } + // Validate Ray job properties + // See https://github.com/aws/aws-cdk/issues/29612 + if (executable.type.name === JobType.RAY.name) { + if (props.workerType !== WorkerType.Z_2X) { + throw new Error(`WorkerType must be Z_2X for Ray jobs, got: ${props.workerType}`); + } + if (props.timeout !== undefined) { + throw new Error('Timeout cannot be set for Ray jobs'); + } + } + let maxCapacity = props.maxCapacity; if (maxCapacity !== undefined && (props.workerType && props.workerCount !== undefined)) { throw new Error('maxCapacity cannot be used when setting workerType and workerCount'); 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 c8df118da127c..dd5d92fd7c3bf 100644 --- a/packages/@aws-cdk/aws-glue-alpha/test/job.test.ts +++ b/packages/@aws-cdk/aws-glue-alpha/test/job.test.ts @@ -896,6 +896,38 @@ describe('Job', () => { workerCount: 2, })).toThrow('Runtime is required for Ray jobs'); }); + + test.each([ + glue.WorkerType.G_025X, + glue.WorkerType.G_1X, + glue.WorkerType.G_2X, + glue.WorkerType.G_4X, + glue.WorkerType.G_8X, + ])('throw error for unsupported worker type', (workerType) => { + 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, + workerCount: 2, + })).toThrow(`WorkerType must be Z_2X for Ray jobs, got: ${workerType}`); + }); + }); + + test('throw error for specifying timeout', () => { + 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, + timeout: cdk.Duration.minutes(5), + })).toThrow('Timeout cannot be set for Ray jobs'); }); test('etl job with all props should synthesize correctly', () => {