# WorkerConfiguration

The worker configuration for a Spark job.

The worker type and the number of workers are set together: providing this
configuration requires both values, so a Spark job can never be given one
without the other.

- Source: [`aws-glue/lib/jobs/spark-job.ts`](https://github.com/aws/aws-cdk/blob/v2.276.0/packages/aws-cdk-lib/aws-glue/lib/jobs/spark-job.ts#L101)
- Type last changed: v2.270.0 · 17 Sep 2026

## Example

```ts
import * as cdk from 'aws-cdk-lib';
import * as iam from 'aws-cdk-lib/aws-iam';
declare const stack: cdk.Stack;
declare const role: iam.IRole;
declare const script: glue.Code;
new glue.PySparkEtlJob(stack, 'PySparkETLJob', {
  jobName: 'PySparkETLJobCustomName',
  description: 'This is a description',
  role,
  script,
  glueVersion: glue.GlueVersion.V6_0,
  continuousLogging: { enabled: false },
  workerConfiguration: {
    workerType: glue.WorkerType.G_2X,
    numberOfWorkers: 2,
  },
  maxConcurrentRuns: 100,
  timeout: cdk.Duration.hours(2),
  connections: [glue.Connection.fromConnectionName(stack, 'Connection', 'connectionName')],
  securityConfiguration: glue.SecurityConfiguration.fromSecurityConfigurationName(stack, 'SecurityConfig', 'securityConfigName'),
  tags: {
    FirstTagName: 'FirstTagValue',
    SecondTagName: 'SecondTagValue',
    XTagName: 'XTagValue',
  },
  maxRetries: 2,
});
```

## Properties

- `numberOfWorkers`: number (required) — The number of workers of the given `workerType` that are allocated when a job runs.

- `workerType`: [WorkerType](/cdk/api/v2/docs/aws-cdk-lib.aws_glue.WorkerType.html) (required) — The type of predefined worker that is allocated when a job runs.

  See the `WorkerType` enum for the full set of supported values.
