# EcsJobDefinition

A JobDefinition that uses ECS orchestration.

Extends: Construct › Resource › EcsJobDefinition
Implements: IResource, IJobDefinition, IEnvironmentAware, IJobDefinitionRef, IConstruct, IDependable

- CloudFormation: [`AWS::Batch::JobDefinition`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-batch-jobdefinition.html)
- L1 type: [`CfnJobDefinition`](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.html)
- Source: [`aws-batch/lib/ecs-job-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-batch/lib/ecs-job-definition.ts#L63)
- Type last changed: v2.247.0 · 2 Apr 2026

## Example

```ts
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
  container: new batch.EcsFargateContainerDefinition(this, 'myFargateContainer', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
    ephemeralStorageSize: cdk.Size.gibibytes(100),
    fargateCpuArchitecture: ecs.CpuArchitecture.ARM64,
    fargateOperatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
  }),
});
```

## Initializer

```ts
new EcsJobDefinition(scope: Construct, id: string, props: EcsJobDefinitionProps)
```

## Construct Props

- `container`: [IEcsContainerDefinition](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IEcsContainerDefinition.html) (required) — The container that this job will run.

- `jobDefinitionName`: string — The name of this job definition.

  **Default:** generated by CloudFormation

- `parameters`: { [key: string]: any } = none — The default parameters passed to the container These parameters can be referenced in the `command` that you give to the container.

- `propagateTags`: boolean = false — Whether to propagate tags from the JobDefinition to the ECS task that Batch spawns.

- `retryAttempts`: number = 1 — The number of times to retry a job.

  The job is retried on failure the same number of attempts as the value.

- `retryStrategies`: [RetryStrategy](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.RetryStrategy.html)[] — Defines the retry behavior for this job.

  **Default:** no `RetryStrategy`

- `schedulingPriority`: number = none — The priority of this Job.

  Only used in Fairshare Scheduling
  to decide which job to run first when there are multiple jobs
  with the same share identifier.

- `skipDeregisterOnUpdate`: boolean — Specifies whether the previous revision of the job definition is retained in an active status after UPDATE events for the resource.

  **Default:** undefined - AWS Batch default is false

  When the property is set to false, the previous revision of the job definition is de-registered after a new revision is created.
  When the property is set to true, the previous revision of the job definition is not de-registered.

- `timeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The timeout time for jobs that are submitted with this job definition.

  **Default:** no timeout

  After the amount of time you specify passes,
  Batch terminates your jobs if they aren't finished.

## Properties

- `container`: [IEcsContainerDefinition](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IEcsContainerDefinition.html) (required) — The container that this job will run.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `jobDefinitionArn`: string (required) — The ARN of this job definition.

- `jobDefinitionName`: string (required) — The name of this job definition.

- `jobDefinitionRef`: [JobDefinitionReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_batch.JobDefinitionReference.html) (required) — A reference to a JobDefinition resource.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `parameters`: { [key: string]: any } — The default parameters passed to the container These parameters can be referenced in the `command` that you give to the container.

- `propagateTags`: boolean — Whether to propagate tags from the JobDefinition to the ECS task that Batch spawns.

- `PROPERTY_INJECTION_ID`: string (required) (static) — Uniquely identifies this class.

- `retryAttempts`: number — The number of times to retry a job.

  The job is retried on failure the same number of attempts as the value.

- `retryStrategies`: [RetryStrategy](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.RetryStrategy.html)[] (required) — Defines the retry behavior for this job.

- `schedulingPriority`: number — The priority of this Job.

  Only used in Fairshare Scheduling
  to decide which job to run first when there are multiple jobs
  with the same share identifier.

- `skipDeregisterOnUpdate`: boolean — Specifies whether the previous revision of the job definition is retained in an active status after UPDATE events for the resource.

  **Default:** undefined - AWS Batch default is false

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

- `timeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The timeout time for jobs that are submitted with this job definition.

  After the amount of time you specify passes,
  Batch terminates your jobs if they aren't finished.

## Methods

- `addRetryStrategy(strategy: RetryStrategy): void` — Add a RetryStrategy to this JobDefinition.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromJobDefinitionArn(scope: Construct, id: string, jobDefinitionArn: string): IJobDefinition` (static) — Import a JobDefinition by its arn.

- `grantSubmitJob(identity: IGrantable, queue: IJobQueueRef): void` — Grants the `batch:submitJob` permission to the identity on both this job definition and the `queue`.

  [disable-awslint:no-grants]

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
