# Code

Represents a Glue Job's Code assets (an asset can be a scripts, a jar, a python file or any other file).

Extends: Code
Superclass of: AssetCode, S3Code

- Source: [`aws-glue/lib/code.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-glue/lib/code.ts#L12)
- 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;

// Create a job to run from the workflow
const job = new glue.PySparkEtlJob(stack, 'Job', { role, script });

// Create a workflow and add a trigger that runs the job
const workflow = new glue.Workflow(stack, 'Workflow');
workflow.addOnDemandTrigger('OnDemandTrigger', {
  actions: [glue.Action.job(job)],
});
```

## Initializer

```ts
new Code()
```

## Methods

- `bind(scope: Construct, grantable: IGrantable): CodeConfig` — Called when the Job is initialized to allow this object to bind.

- `fromAsset(path: string, options?: AssetOptions): AssetCode` (static) — Job code from a local disk path.

  **Parameters**

  - `path` — code file (not a directory).

- `fromBucket(bucket: IBucket, key: string): S3Code` (static) — Job code as an S3 object.

  **Parameters**

  - `bucket` — The S3 bucket.
  - `key` — The object key.
