# AWS Batch Construct Library

This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

AWS Batch is a batch processing tool for efficiently running hundreds of thousands computing jobs in AWS.
Batch can dynamically provision [Amazon EC2](https://aws.amazon.com/ec2/) Instances to meet the resource requirements of submitted jobs
and simplifies the planning, scheduling, and executions of your batch workloads. Batch achieves this through four different resources:

* ComputeEnvironments: Contain the resources used to execute Jobs
* JobDefinitions: Define a type of Job that can be submitted
* JobQueues: Route waiting Jobs to ComputeEnvironments
* SchedulingPolicies: Applied to Queues to control how and when Jobs exit the JobQueue and enter the ComputeEnvironment

`ComputeEnvironment`s can be managed or unmanaged. Batch will automatically provision EC2 Instances in a managed `ComputeEnvironment` and will
not provision any Instances in an unmanaged `ComputeEnvironment`. Managed `ComputeEnvironment`s can use ECS, Fargate, or EKS resources to spin up
EC2 Instances in (ensure your EKS Cluster has [been configured](https://docs.aws.amazon.com/batch/latest/userguide/getting-started-eks.html)
to support a Batch ComputeEnvironment before linking it). You can use Launch Templates and Placement Groups to configure exactly how these resources
will be provisioned.

`JobDefinition`s can use either ECS resources or EKS resources. ECS `JobDefinition`s can use multiple containers to execute distributed workloads.
EKS `JobDefinition`s can only execute a single container. Submitted Jobs use `JobDefinition`s as templates.

`JobQueue`s must link at least one `ComputeEnvironment`. Jobs exit the Queue in FIFO order unless a `SchedulingPolicy` is specified.

`SchedulingPolicy`s tell the Scheduler how to choose which Jobs should be executed next by the ComputeEnvironment.

## Use Cases & Examples

### Cost Optimization

#### Spot Instances

Spot instances are significantly discounted EC2 instances that can be reclaimed at any time by AWS.
Workloads that are fault-tolerant or stateless can take advantage of spot pricing.
To use spot spot instances, set `spot` to `true` on a managed Ec2 or Fargate Compute Environment:

TypeScript:

```ts
const vpc = new ec2.Vpc(this, 'VPC');
new batch.FargateComputeEnvironment(this, 'myFargateComputeEnv', {
  vpc,
  spot: true,
});
```

Python:

```python
vpc = ec2.Vpc(self, "VPC")
batch.FargateComputeEnvironment(self, "myFargateComputeEnv",
    vpc=vpc,
    spot=True
)
```

Java:

```java
Vpc vpc = new Vpc(this, "VPC");
FargateComputeEnvironment.Builder.create(this, "myFargateComputeEnv")
        .vpc(vpc)
        .spot(true)
        .build();
```

C# / .NET:

```csharp
var vpc = new Vpc(this, "VPC");
new FargateComputeEnvironment(this, "myFargateComputeEnv", new FargateComputeEnvironmentProps {
    Vpc = vpc,
    Spot = true
});
```

Golang:

```go
vpc := ec2.NewVpc(this, jsii.String("VPC"))
batch.NewFargateComputeEnvironment(this, jsii.String("myFargateComputeEnv"), &FargateComputeEnvironmentProps{
	Vpc: Vpc,
	Spot: jsii.Boolean(true),
})
```

Batch allows you to specify the percentage of the on-demand instance that the current spot price
must be to provision the instance using the `spotBidPercentage`.
This defaults to 100%, which is the recommended value.
This value cannot be specified for `FargateComputeEnvironment`s
and only applies to `ManagedEc2EcsComputeEnvironment`s.
The following code configures a Compute Environment to only use spot instances that
are at most 20% the price of the on-demand instance price:

_Note_: For [`FargateComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.FargateComputeEnvironment.html), while the [`FargateComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.FargateComputeEnvironmentProps.html) interface includes properties like `replaceComputeEnvironment`, `terminateOnUpdate`, `updateTimeout`, and `updateToLatestImageVersion`, these specific properties are **not applicable** when configuring AWS Batch Fargate compute environments. They primarily apply to EC2-based compute environments. Please refer to the official [AWS Batch UpdateComputeEnvironment API documentation](https://docs.aws.amazon.com/batch/latest/APIReference/API_UpdateComputeEnvironment.html) and [User Guide](https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html) for details on updating Fargate compute environments.

TypeScript:

```ts
const vpc = new ec2.Vpc(this, 'VPC');
new batch.ManagedEc2EcsComputeEnvironment(this, 'myEc2ComputeEnv', {
   vpc,
   spot: true,
   spotBidPercentage: 20,
});
```

Python:

```python
vpc = ec2.Vpc(self, "VPC")
batch.ManagedEc2EcsComputeEnvironment(self, "myEc2ComputeEnv",
    vpc=vpc,
    spot=True,
    spot_bid_percentage=20
)
```

Java:

```java
Vpc vpc = new Vpc(this, "VPC");
ManagedEc2EcsComputeEnvironment.Builder.create(this, "myEc2ComputeEnv")
        .vpc(vpc)
        .spot(true)
        .spotBidPercentage(20)
        .build();
```

C# / .NET:

```csharp
var vpc = new Vpc(this, "VPC");
new ManagedEc2EcsComputeEnvironment(this, "myEc2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    Spot = true,
    SpotBidPercentage = 20
});
```

Golang:

```go
vpc := ec2.NewVpc(this, jsii.String("VPC"))
batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("myEc2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	Spot: jsii.Boolean(true),
	SpotBidPercentage: jsii.Number(20),
})
```

For stateful or otherwise non-interruption-tolerant workflows, omit `spot` or set it to `false` to only provision on-demand instances.

#### Choosing Your Instance Types

There are several ways to configure instance types for your compute environment:

##### Using Default Instance Classes (Recommended)

AWS Batch provides default instance classes that automatically select cost-effective, up-to-date instances based on your region.
This is the recommended approach for new projects:

TypeScript:

```ts
const vpc = new ec2.Vpc(this, 'Vpc');

// Use ARM64 instances (e.g., m6g, c6g, r6g, c7g families)
new batch.ManagedEc2EcsComputeEnvironment(this, 'Arm64Ec2ComputeEnv', {
  vpc,
  defaultInstanceClasses: [batch.DefaultInstanceClass.ARM64],
});

// Use x86_64 instances (e.g., m6i, c6i, r6i, c7i families)
new batch.ManagedEc2EcsComputeEnvironment(this, 'X86_64Ec2ComputeEnv', {
  vpc,
  defaultInstanceClasses: [batch.DefaultInstanceClass.X86_64],
});
```

Python:

```python
vpc = ec2.Vpc(self, "Vpc")

# Use ARM64 instances (e.g., m6g, c6g, r6g, c7g families)
batch.ManagedEc2EcsComputeEnvironment(self, "Arm64Ec2ComputeEnv",
    vpc=vpc,
    default_instance_classes=[batch.DefaultInstanceClass.ARM64]
)

# Use x86_64 instances (e.g., m6i, c6i, r6i, c7i families)
batch.ManagedEc2EcsComputeEnvironment(self, "X86_64Ec2ComputeEnv",
    vpc=vpc,
    default_instance_classes=[batch.DefaultInstanceClass.X86_64]
)
```

Java:

```java
Vpc vpc = new Vpc(this, "Vpc");

// Use ARM64 instances (e.g., m6g, c6g, r6g, c7g families)
// Use ARM64 instances (e.g., m6g, c6g, r6g, c7g families)
ManagedEc2EcsComputeEnvironment.Builder.create(this, "Arm64Ec2ComputeEnv")
        .vpc(vpc)
        .defaultInstanceClasses(List.of(DefaultInstanceClass.ARM64))
        .build();

// Use x86_64 instances (e.g., m6i, c6i, r6i, c7i families)
// Use x86_64 instances (e.g., m6i, c6i, r6i, c7i families)
ManagedEc2EcsComputeEnvironment.Builder.create(this, "X86_64Ec2ComputeEnv")
        .vpc(vpc)
        .defaultInstanceClasses(List.of(DefaultInstanceClass.X86_64))
        .build();
```

C# / .NET:

```csharp
var vpc = new Vpc(this, "Vpc");

// Use ARM64 instances (e.g., m6g, c6g, r6g, c7g families)
// Use ARM64 instances (e.g., m6g, c6g, r6g, c7g families)
new ManagedEc2EcsComputeEnvironment(this, "Arm64Ec2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    DefaultInstanceClasses = new [] { DefaultInstanceClass.ARM64 }
});

// Use x86_64 instances (e.g., m6i, c6i, r6i, c7i families)
// Use x86_64 instances (e.g., m6i, c6i, r6i, c7i families)
new ManagedEc2EcsComputeEnvironment(this, "X86_64Ec2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    DefaultInstanceClasses = new [] { DefaultInstanceClass.X86_64 }
});
```

Golang:

```go
vpc := ec2.NewVpc(this, jsii.String("Vpc"))

// Use ARM64 instances (e.g., m6g, c6g, r6g, c7g families)
// Use ARM64 instances (e.g., m6g, c6g, r6g, c7g families)
batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("Arm64Ec2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	DefaultInstanceClasses: []DefaultInstanceClass{
		batch.DefaultInstanceClass_ARM64,
	},
})

// Use x86_64 instances (e.g., m6i, c6i, r6i, c7i families)
// Use x86_64 instances (e.g., m6i, c6i, r6i, c7i families)
batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("X86_64Ec2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	DefaultInstanceClasses: []DefaultInstanceClass{
		batch.DefaultInstanceClass_X86_64,
	},
})
```

The `default_x86_64` and `default_arm64` categories are dynamically updated by AWS as new instance families become available in your region.

##### Using Specific Instance Types Only

To use only specific instance types without any automatic defaults, set `useOptimalInstanceClasses: false`:

TypeScript:

```ts
const vpc = new ec2.Vpc(this, 'Vpc');

// Use only R4 instance class (Batch chooses the size)
new batch.ManagedEc2EcsComputeEnvironment(this, 'R4Ec2ComputeEnv', {
  vpc,
  useOptimalInstanceClasses: false,
  instanceClasses: [ec2.InstanceClass.R4],
});

// Use only a specific instance type
new batch.ManagedEc2EcsComputeEnvironment(this, 'M5AdLargeEc2ComputeEnv', {
  vpc,
  useOptimalInstanceClasses: false,
  instanceTypes: [ec2.InstanceType.of(ec2.InstanceClass.M5AD, ec2.InstanceSize.LARGE)],
});
```

Python:

```python
vpc = ec2.Vpc(self, "Vpc")

# Use only R4 instance class (Batch chooses the size)
batch.ManagedEc2EcsComputeEnvironment(self, "R4Ec2ComputeEnv",
    vpc=vpc,
    use_optimal_instance_classes=False,
    instance_classes=[ec2.InstanceClass.R4]
)

# Use only a specific instance type
batch.ManagedEc2EcsComputeEnvironment(self, "M5AdLargeEc2ComputeEnv",
    vpc=vpc,
    use_optimal_instance_classes=False,
    instance_types=[ec2.InstanceType.of(ec2.InstanceClass.M5AD, ec2.InstanceSize.LARGE)]
)
```

Java:

```java
Vpc vpc = new Vpc(this, "Vpc");

// Use only R4 instance class (Batch chooses the size)
// Use only R4 instance class (Batch chooses the size)
ManagedEc2EcsComputeEnvironment.Builder.create(this, "R4Ec2ComputeEnv")
        .vpc(vpc)
        .useOptimalInstanceClasses(false)
        .instanceClasses(List.of(InstanceClass.R4))
        .build();

// Use only a specific instance type
// Use only a specific instance type
ManagedEc2EcsComputeEnvironment.Builder.create(this, "M5AdLargeEc2ComputeEnv")
        .vpc(vpc)
        .useOptimalInstanceClasses(false)
        .instanceTypes(List.of(InstanceType.of(InstanceClass.M5AD, InstanceSize.LARGE)))
        .build();
```

C# / .NET:

```csharp
var vpc = new Vpc(this, "Vpc");

// Use only R4 instance class (Batch chooses the size)
// Use only R4 instance class (Batch chooses the size)
new ManagedEc2EcsComputeEnvironment(this, "R4Ec2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    UseOptimalInstanceClasses = false,
    InstanceClasses = new [] { InstanceClass.R4 }
});

// Use only a specific instance type
// Use only a specific instance type
new ManagedEc2EcsComputeEnvironment(this, "M5AdLargeEc2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    UseOptimalInstanceClasses = false,
    InstanceTypes = new [] { InstanceType.Of(InstanceClass.M5AD, InstanceSize.LARGE) }
});
```

Golang:

```go
vpc := ec2.NewVpc(this, jsii.String("Vpc"))

// Use only R4 instance class (Batch chooses the size)
// Use only R4 instance class (Batch chooses the size)
batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("R4Ec2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	UseOptimalInstanceClasses: jsii.Boolean(false),
	InstanceClasses: []InstanceClass{
		ec2.InstanceClass_R4,
	},
})

// Use only a specific instance type
// Use only a specific instance type
batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("M5AdLargeEc2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	UseOptimalInstanceClasses: jsii.Boolean(false),
	InstanceTypes: []InstanceType{
		ec2.InstanceType_Of(ec2.InstanceClass_M5AD, ec2.InstanceSize_LARGE),
	},
})
```

##### Using Optimal Instance Classes

By default, `useOptimalInstanceClasses` is `true`, which adds the `optimal` instance type.

**Note**: Since November 2025, `optimal` behaves the same as `default_x86_64` and is dynamically updated as AWS introduces new instance families. Both options automatically select cost-effective x86_64 instance types (from the m6i, c6i, r6i, and c7i families) based on your region.

You can combine this with additional instance types:

TypeScript:

```ts
declare const vpc: ec2.IVpc;

const computeEnv = new batch.ManagedEc2EcsComputeEnvironment(this, 'Ec2ComputeEnv', {
  vpc,
  instanceTypes: [ec2.InstanceType.of(ec2.InstanceClass.M5AD, ec2.InstanceSize.LARGE)],
  // useOptimalInstanceClasses: true (default)
});
// Result: ['m5ad.large', 'optimal']
```

Python:

```python
# vpc: ec2.IVpc

compute_env = batch.ManagedEc2EcsComputeEnvironment(self, "Ec2ComputeEnv",
    vpc=vpc,
    instance_types=[ec2.InstanceType.of(ec2.InstanceClass.M5AD, ec2.InstanceSize.LARGE)]
)
```

Java:

```java
IVpc vpc;

ManagedEc2EcsComputeEnvironment computeEnv = ManagedEc2EcsComputeEnvironment.Builder.create(this, "Ec2ComputeEnv")
        .vpc(vpc)
        .instanceTypes(List.of(InstanceType.of(InstanceClass.M5AD, InstanceSize.LARGE)))
        .build();
```

C# / .NET:

```csharp
IVpc vpc;

var computeEnv = new ManagedEc2EcsComputeEnvironment(this, "Ec2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    InstanceTypes = new [] { InstanceType.Of(InstanceClass.M5AD, InstanceSize.LARGE) }
});
```

Golang:

```go
var vpc IVpc

computeEnv := batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("Ec2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	InstanceTypes: []InstanceType{
		ec2.InstanceType_Of(ec2.InstanceClass_M5AD, ec2.InstanceSize_LARGE),
	},
})
```

##### Instance Type Configuration Reference

| Goal | Configuration |
|------|---------------|
| Use latest x86_64 instances | `defaultInstanceClasses: [DefaultInstanceClass.X86_64]` or no configuration (default) |
| Use latest ARM64 instances | `defaultInstanceClasses: [DefaultInstanceClass.ARM64]` |
| Use only specific instance classes | `useOptimalInstanceClasses: false` + `instanceClasses: [...]` |
| Use only specific instance types | `useOptimalInstanceClasses: false` + `instanceTypes: [...]` |
| Use optimal + additional instances | `instanceClasses: [...]` or `instanceTypes: [...]` |

**Note**: Batch does not allow specifying instance types or classes with different architectures.
For example, `InstanceClass.A1` (ARM) cannot be specified alongside `optimal` (x86_64).
When using ARM-based instances (e.g., Graviton), use `defaultInstanceClasses: [DefaultInstanceClass.ARM64]`, or set `useOptimalInstanceClasses: false` and explicitly specify ARM instance classes/types.

**Note**: `useOptimalInstanceClasses` and `defaultInstanceClasses` cannot be used together.

#### Configure AMIs

You can configure Amazon Machine Images (AMIs). This example configures your `ComputeEnvironment` to use Amazon Linux 2023.

TypeScript:

```ts
declare const vpc: ec2.IVpc;

new batch.ManagedEc2EcsComputeEnvironment(this, 'myEc2ComputeEnv', {
  vpc,
  images: [
    {
      imageType: batch.EcsMachineImageType.ECS_AL2023,
    },
  ],
});
```

Python:

```python
# vpc: ec2.IVpc

batch.ManagedEc2EcsComputeEnvironment(self, "myEc2ComputeEnv",
    vpc=vpc,
    images=[batch.EcsMachineImage(
        image_type=batch.EcsMachineImageType.ECS_AL2023
    )
    ]
)
```

Java:

```java
IVpc vpc;

ManagedEc2EcsComputeEnvironment.Builder.create(this, "myEc2ComputeEnv")
        .vpc(vpc)
        .images(List.of(EcsMachineImage.builder()
                .imageType(EcsMachineImageType.ECS_AL2023)
                .build()))
        .build();
```

C# / .NET:

```csharp
IVpc vpc;

new ManagedEc2EcsComputeEnvironment(this, "myEc2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    Images = new [] { new EcsMachineImage {
        ImageType = EcsMachineImageType.ECS_AL2023
    } }
});
```

Golang:

```go
var vpc IVpc

batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("myEc2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	Images: []EcsMachineImage{
		&EcsMachineImage{
			ImageType: batch.EcsMachineImageType_ECS_AL2023,
		},
	},
})
```

If your image needs GPU resources, specify `ECS_AL2023_NVIDIA`:

TypeScript:

```ts
declare const vpc: ec2.IVpc;

new batch.ManagedEc2EcsComputeEnvironment(this, 'myGpuComputeEnv', {
  vpc,
  images: [
    {
      imageType: batch.EcsMachineImageType.ECS_AL2023_NVIDIA,
    },
  ],
});
```

Python:

```python
# vpc: ec2.IVpc

batch.ManagedEc2EcsComputeEnvironment(self, "myGpuComputeEnv",
    vpc=vpc,
    images=[batch.EcsMachineImage(
        image_type=batch.EcsMachineImageType.ECS_AL2023_NVIDIA
    )
    ]
)
```

Java:

```java
IVpc vpc;

ManagedEc2EcsComputeEnvironment.Builder.create(this, "myGpuComputeEnv")
        .vpc(vpc)
        .images(List.of(EcsMachineImage.builder()
                .imageType(EcsMachineImageType.ECS_AL2023_NVIDIA)
                .build()))
        .build();
```

C# / .NET:

```csharp
IVpc vpc;

new ManagedEc2EcsComputeEnvironment(this, "myGpuComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    Images = new [] { new EcsMachineImage {
        ImageType = EcsMachineImageType.ECS_AL2023_NVIDIA
    } }
});
```

Golang:

```go
var vpc IVpc

batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("myGpuComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	Images: []EcsMachineImage{
		&EcsMachineImage{
			ImageType: batch.EcsMachineImageType_ECS_AL2023_NVIDIA,
		},
	},
})
```

#### Allocation Strategies

| Allocation Strategy           | Optimized for              | Downsides                     |
| -----------------------       | -------------              | ----------------------------- |
| BEST_FIT                      | Cost                       | May limit throughput          |
| BEST_FIT_PROGRESSIVE          | Throughput                 | May increase cost             |
| SPOT_CAPACITY_OPTIMIZED       | Least interruption         | Only useful on Spot instances |
| SPOT_PRICE_CAPACITY_OPTIMIZED | Least interruption + Price | Only useful on Spot instances |

Batch provides different Allocation Strategies to help it choose which instances to provision.
If your workflow tolerates interruptions, you should enable `spot` on your `ComputeEnvironment`
and use `SPOT_PRICE_CAPACITY_OPTIMIZED` (this is the default if `spot` is enabled).
This will tell Batch to choose the instance types from the ones you’ve specified that have
the most spot capacity available to minimize the chance of interruption and have the lowest price.
To get the most benefit from your spot instances,
you should allow Batch to choose from as many different instance types as possible.
If you only care about minimal interruptions and not want Batch to optimize for cost, use
`SPOT_CAPACITY_OPTIMIZED`. `SPOT_PRICE_CAPACITY_OPTIMIZED` is recommended over `SPOT_CAPACITY_OPTIMIZED`
for most use cases.

If your workflow does not tolerate interruptions and you want to minimize your costs at the expense
of potentially longer waiting times, use `AllocationStrategy.BEST_FIT`.
This will choose the lowest-cost instance type that fits all the jobs in the queue.
If instances of that type are not available,
the queue will not choose a new type; instead, it will wait for the instance to become available.
This can stall your `Queue`, with your compute environment only using part of its max capacity
(or none at all) until the `BEST_FIT` instance becomes available.

If you are running a workflow that does not tolerate interruptions and you want to maximize throughput,
you can use `AllocationStrategy.BEST_FIT_PROGRESSIVE`.
This is the default Allocation Strategy if `spot` is `false` or unspecified.
This strategy will examine the Jobs in the queue and choose whichever instance type meets the requirements
of the jobs in the queue and with the lowest cost per vCPU, just as `BEST_FIT`.
However, if not all of the capacity can be filled with this instance type,
it will choose a new next-best instance type to run any jobs that couldn’t fit into the `BEST_FIT` capacity.
To make the most use of this allocation strategy,
it is recommended to use as many instance classes as is feasible for your workload.
This example shows a `ComputeEnvironment` that uses `BEST_FIT_PROGRESSIVE`
with `'optimal'` and `InstanceClass.M5` instance types:

TypeScript:

```ts
declare const vpc: ec2.IVpc;

const computeEnv = new batch.ManagedEc2EcsComputeEnvironment(this, 'myEc2ComputeEnv', {
  vpc,
  instanceClasses: [ec2.InstanceClass.M5],
});
```

Python:

```python
# vpc: ec2.IVpc

compute_env = batch.ManagedEc2EcsComputeEnvironment(self, "myEc2ComputeEnv",
    vpc=vpc,
    instance_classes=[ec2.InstanceClass.M5]
)
```

Java:

```java
IVpc vpc;

ManagedEc2EcsComputeEnvironment computeEnv = ManagedEc2EcsComputeEnvironment.Builder.create(this, "myEc2ComputeEnv")
        .vpc(vpc)
        .instanceClasses(List.of(InstanceClass.M5))
        .build();
```

C# / .NET:

```csharp
IVpc vpc;

var computeEnv = new ManagedEc2EcsComputeEnvironment(this, "myEc2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    InstanceClasses = new [] { InstanceClass.M5 }
});
```

Golang:

```go
var vpc IVpc

computeEnv := batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("myEc2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	InstanceClasses: []InstanceClass{
		ec2.InstanceClass_M5,
	},
})
```

This example shows a `ComputeEnvironment` that uses `BEST_FIT` with `'optimal'` instances:

TypeScript:

```ts
declare const vpc: ec2.IVpc;

const computeEnv = new batch.ManagedEc2EcsComputeEnvironment(this, 'myEc2ComputeEnv', {
  vpc,
  allocationStrategy: batch.AllocationStrategy.BEST_FIT,
});
```

Python:

```python
# vpc: ec2.IVpc

compute_env = batch.ManagedEc2EcsComputeEnvironment(self, "myEc2ComputeEnv",
    vpc=vpc,
    allocation_strategy=batch.AllocationStrategy.BEST_FIT
)
```

Java:

```java
IVpc vpc;

ManagedEc2EcsComputeEnvironment computeEnv = ManagedEc2EcsComputeEnvironment.Builder.create(this, "myEc2ComputeEnv")
        .vpc(vpc)
        .allocationStrategy(AllocationStrategy.BEST_FIT)
        .build();
```

C# / .NET:

```csharp
IVpc vpc;

var computeEnv = new ManagedEc2EcsComputeEnvironment(this, "myEc2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    AllocationStrategy = AllocationStrategy.BEST_FIT
});
```

Golang:

```go
var vpc IVpc

computeEnv := batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("myEc2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	AllocationStrategy: batch.AllocationStrategy_BEST_FIT,
})
```

*Note*: `allocationStrategy` cannot be specified on Fargate Compute Environments.

### Controlling vCPU allocation

You can specify the maximum and minimum vCPUs a managed `ComputeEnvironment` can have at any given time.
Batch will *always* maintain `minvCpus` worth of instances in your ComputeEnvironment, even if it is not executing any jobs,
and even if it is disabled. Batch will scale the instances up to `maxvCpus` worth of instances as
jobs exit the JobQueue and enter the ComputeEnvironment. If you use `AllocationStrategy.BEST_FIT_PROGRESSIVE`,
`AllocationStrategy.SPOT_PRICE_CAPACITY_OPTIMIZED`, or `AllocationStrategy.SPOT_CAPACITY_OPTIMIZED`,
batch may exceed `maxvCpus`; it will never exceed `maxvCpus` by more than a single instance type. This example configures a
`minvCpus` of 10 and a `maxvCpus` of 100:

TypeScript:

```ts
declare const vpc: ec2.IVpc;

new batch.ManagedEc2EcsComputeEnvironment(this, 'myEc2ComputeEnv', {
  vpc,
  instanceClasses: [ec2.InstanceClass.R4],
  minvCpus: 10,
  maxvCpus: 100,
});
```

Python:

```python
# vpc: ec2.IVpc

batch.ManagedEc2EcsComputeEnvironment(self, "myEc2ComputeEnv",
    vpc=vpc,
    instance_classes=[ec2.InstanceClass.R4],
    minv_cpus=10,
    maxv_cpus=100
)
```

Java:

```java
IVpc vpc;

ManagedEc2EcsComputeEnvironment.Builder.create(this, "myEc2ComputeEnv")
        .vpc(vpc)
        .instanceClasses(List.of(InstanceClass.R4))
        .minvCpus(10)
        .maxvCpus(100)
        .build();
```

C# / .NET:

```csharp
IVpc vpc;

new ManagedEc2EcsComputeEnvironment(this, "myEc2ComputeEnv", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc,
    InstanceClasses = new [] { InstanceClass.R4 },
    MinvCpus = 10,
    MaxvCpus = 100
});
```

Golang:

```go
var vpc IVpc

batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("myEc2ComputeEnv"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
	InstanceClasses: []InstanceClass{
		ec2.InstanceClass_R4,
	},
	MinvCpus: jsii.Number(10),
	MaxvCpus: jsii.Number(100),
})
```

### Tagging Instances

You can tag any instances launched by your managed EC2 ComputeEnvironments by using the CDK `Tags` API:

TypeScript:

```ts
declare const vpc: ec2.IVpc;

const tagCE = new batch.ManagedEc2EcsComputeEnvironment(this, 'CEThatMakesTaggedInstnaces', {
  vpc,
});

Tags.of(tagCE).add('super', 'salamander');
```

Python:

```python
# vpc: ec2.IVpc

tag_ce = batch.ManagedEc2EcsComputeEnvironment(self, "CEThatMakesTaggedInstnaces",
    vpc=vpc
)

Tags.of(tag_ce).add("super", "salamander")
```

Java:

```java
IVpc vpc;

ManagedEc2EcsComputeEnvironment tagCE = ManagedEc2EcsComputeEnvironment.Builder.create(this, "CEThatMakesTaggedInstnaces")
        .vpc(vpc)
        .build();

Tags.of(tagCE).add("super", "salamander");
```

C# / .NET:

```csharp
IVpc vpc;

var tagCE = new ManagedEc2EcsComputeEnvironment(this, "CEThatMakesTaggedInstnaces", new ManagedEc2EcsComputeEnvironmentProps {
    Vpc = vpc
});

Tags.Of(tagCE).Add("super", "salamander");
```

Golang:

```go
var vpc IVpc

tagCE := batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("CEThatMakesTaggedInstnaces"), &ManagedEc2EcsComputeEnvironmentProps{
	Vpc: Vpc,
})

awscdk.Tags_Of(tagCE).Add(jsii.String("super"), jsii.String("salamander"))
```

Unmanaged `ComputeEnvironment`s do not support `maxvCpus` or `minvCpus` because you must provision and manage the instances yourself;
that is, Batch will not scale them up and down as needed.

### Sharing a ComputeEnvironment between multiple JobQueues

Multiple `JobQueue`s can share the same `ComputeEnvironment`.
If multiple Queues are attempting to submit Jobs to the same `ComputeEnvironment`,
Batch will pick the Job from the Queue with the highest priority.
This example creates two `JobQueue`s that share a `ComputeEnvironment`:

TypeScript:

```ts
declare const vpc: ec2.IVpc;
const sharedComputeEnv = new batch.FargateComputeEnvironment(this, 'spotEnv', {
  vpc,
  spot: true,
});
const lowPriorityQueue = new batch.JobQueue(this, 'JobQueue', {
   priority: 1,
});
const highPriorityQueue = new batch.JobQueue(this, 'JobQueue', {
   priority: 10,
});
lowPriorityQueue.addComputeEnvironment(sharedComputeEnv, 1);
highPriorityQueue.addComputeEnvironment(sharedComputeEnv, 1);
```

Python:

```python
# vpc: ec2.IVpc

shared_compute_env = batch.FargateComputeEnvironment(self, "spotEnv",
    vpc=vpc,
    spot=True
)
low_priority_queue = batch.JobQueue(self, "JobQueue",
    priority=1
)
high_priority_queue = batch.JobQueue(self, "JobQueue",
    priority=10
)
low_priority_queue.add_compute_environment(shared_compute_env, 1)
high_priority_queue.add_compute_environment(shared_compute_env, 1)
```

Java:

```java
IVpc vpc;

FargateComputeEnvironment sharedComputeEnv = FargateComputeEnvironment.Builder.create(this, "spotEnv")
        .vpc(vpc)
        .spot(true)
        .build();
JobQueue lowPriorityQueue = JobQueue.Builder.create(this, "JobQueue")
        .priority(1)
        .build();
JobQueue highPriorityQueue = JobQueue.Builder.create(this, "JobQueue")
        .priority(10)
        .build();
lowPriorityQueue.addComputeEnvironment(sharedComputeEnv, 1);
highPriorityQueue.addComputeEnvironment(sharedComputeEnv, 1);
```

C# / .NET:

```csharp
IVpc vpc;

var sharedComputeEnv = new FargateComputeEnvironment(this, "spotEnv", new FargateComputeEnvironmentProps {
    Vpc = vpc,
    Spot = true
});
var lowPriorityQueue = new JobQueue(this, "JobQueue", new JobQueueProps {
    Priority = 1
});
var highPriorityQueue = new JobQueue(this, "JobQueue", new JobQueueProps {
    Priority = 10
});
lowPriorityQueue.AddComputeEnvironment(sharedComputeEnv, 1);
highPriorityQueue.AddComputeEnvironment(sharedComputeEnv, 1);
```

Golang:

```go
var vpc IVpc

sharedComputeEnv := batch.NewFargateComputeEnvironment(this, jsii.String("spotEnv"), &FargateComputeEnvironmentProps{
	Vpc: Vpc,
	Spot: jsii.Boolean(true),
})
lowPriorityQueue := batch.NewJobQueue(this, jsii.String("JobQueue"), &JobQueueProps{
	Priority: jsii.Number(1),
})
highPriorityQueue := batch.NewJobQueue(this, jsii.String("JobQueue"), &JobQueueProps{
	Priority: jsii.Number(10),
})
lowPriorityQueue.AddComputeEnvironment(sharedComputeEnv, jsii.Number(1))
highPriorityQueue.AddComputeEnvironment(sharedComputeEnv, jsii.Number(1))
```

### React to jobs stuck in RUNNABLE state

You can react to jobs stuck in RUNNABLE state by setting a `jobStateTimeLimitActions` in [`JobQueue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobQueue.html).
Specifies actions that AWS Batch will take after the job has remained at the head of the queue in the
specified state for longer than the specified time.

TypeScript:

```ts
new batch.JobQueue(this, 'JobQueue', {
    jobStateTimeLimitActions: [
      {
        action: batch.JobStateTimeLimitActionsAction.CANCEL,
        maxTime: cdk.Duration.minutes(10),
        reason: batch.JobStateTimeLimitActionsReason.INSUFFICIENT_INSTANCE_CAPACITY,
        state: batch.JobStateTimeLimitActionsState.RUNNABLE,
      },
    ]
});
```

Python:

```python
batch.JobQueue(self, "JobQueue",
    job_state_time_limit_actions=[batch.JobStateTimeLimitAction(
        action=batch.JobStateTimeLimitActionsAction.CANCEL,
        max_time=cdk.Duration.minutes(10),
        reason=batch.JobStateTimeLimitActionsReason.INSUFFICIENT_INSTANCE_CAPACITY,
        state=batch.JobStateTimeLimitActionsState.RUNNABLE
    )
    ]
)
```

Java:

```java
JobQueue.Builder.create(this, "JobQueue")
        .jobStateTimeLimitActions(List.of(JobStateTimeLimitAction.builder()
                .action(JobStateTimeLimitActionsAction.CANCEL)
                .maxTime(Duration.minutes(10))
                .reason(JobStateTimeLimitActionsReason.INSUFFICIENT_INSTANCE_CAPACITY)
                .state(JobStateTimeLimitActionsState.RUNNABLE)
                .build()))
        .build();
```

C# / .NET:

```csharp
new JobQueue(this, "JobQueue", new JobQueueProps {
    JobStateTimeLimitActions = new [] { new JobStateTimeLimitAction {
        Action = JobStateTimeLimitActionsAction.CANCEL,
        MaxTime = Duration.Minutes(10),
        Reason = JobStateTimeLimitActionsReason.INSUFFICIENT_INSTANCE_CAPACITY,
        State = JobStateTimeLimitActionsState.RUNNABLE
    } }
});
```

Golang:

```go
batch.NewJobQueue(this, jsii.String("JobQueue"), &JobQueueProps{
	JobStateTimeLimitActions: []JobStateTimeLimitAction{
		&JobStateTimeLimitAction{
			Action: batch.JobStateTimeLimitActionsAction_CANCEL,
			MaxTime: cdk.Duration_Minutes(jsii.Number(10)),
			Reason: batch.JobStateTimeLimitActionsReason_INSUFFICIENT_INSTANCE_CAPACITY,
			State: batch.JobStateTimeLimitActionsState_RUNNABLE,
		},
	},
})
```

### Fairshare Scheduling

Batch `JobQueue`s execute Jobs submitted to them in FIFO order unless you specify a `SchedulingPolicy`.
FIFO queuing can cause short-running jobs to be starved while long-running jobs fill the compute environment.
To solve this, Jobs can be associated with a share.

Shares consist of a `shareIdentifier` and a `weightFactor`, which is inversely correlated with the vCPU allocated to that share identifier.
When submitting a Job, you can specify its `shareIdentifier` to associate that particular job with that share.
Let's see how the scheduler uses this information to schedule jobs.

For example, if there are two shares defined as follows:

| Share Identifier | Weight Factor |
| ---------------- | ------------- |
| A                | 1             |
| B                | 1             |

The weight factors share the following relationship:

$$
A_{vCpus} / A_{Weight} = B_{vCpus} / B_{Weight}
$$

where `BvCpus` is the number of vCPUs allocated to jobs with share identifier `'B'`, and `B_weight` is the weight factor of `B`.

The total number of vCpus allocated to a share is equal to the amount of jobs in that share times the number of vCpus necessary for every job.
Let's say that each A job needs 32 VCpus (`A_requirement` = 32) and each B job needs 64 vCpus (`B_requirement` = 64):

$$
A_{vCpus} = A_{Jobs} * A_{Requirement}
$$

$$
B_{vCpus} = B_{Jobs} * B_{Requirement}
$$

We have:

$$
A_{vCpus} / A_{Weight} = B_{vCpus} / B_{Weight}
$$

$$
A_{Jobs} * A_{Requirement} / A_{Weight} = B_{Jobs} * B_{Requirement} / B_{Weight}
$$

$$
A_{Jobs} * 32 / 1 = B_{Jobs} * 64 / 1
$$

$$
A_{Jobs} * 32 = B_{Jobs} * 64
$$

$$
A_{Jobs} = B_{Jobs} * 2
$$

Thus the scheduler will schedule two `'A'` jobs for each `'B'` job.

You can control the weight factors to change these ratios, but note that
weight factors are inversely correlated with the vCpus allocated to the corresponding share.

This example would be configured like this:

TypeScript:

```ts
const fairsharePolicy = new batch.FairshareSchedulingPolicy(this, 'myFairsharePolicy');

fairsharePolicy.addShare({
  shareIdentifier: 'A',
  weightFactor: 1,
});
fairsharePolicy.addShare({
  shareIdentifier: 'B',
  weightFactor: 1,
});
new batch.JobQueue(this, 'JobQueue', {
  schedulingPolicy: fairsharePolicy,
});
```

Python:

```python
fairshare_policy = batch.FairshareSchedulingPolicy(self, "myFairsharePolicy")

fairshare_policy.add_share(
    share_identifier="A",
    weight_factor=1
)
fairshare_policy.add_share(
    share_identifier="B",
    weight_factor=1
)
batch.JobQueue(self, "JobQueue",
    scheduling_policy=fairshare_policy
)
```

Java:

```java
FairshareSchedulingPolicy fairsharePolicy = new FairshareSchedulingPolicy(this, "myFairsharePolicy");

fairsharePolicy.addShare(Share.builder()
        .shareIdentifier("A")
        .weightFactor(1)
        .build());
fairsharePolicy.addShare(Share.builder()
        .shareIdentifier("B")
        .weightFactor(1)
        .build());
JobQueue.Builder.create(this, "JobQueue")
        .schedulingPolicy(fairsharePolicy)
        .build();
```

C# / .NET:

```csharp
var fairsharePolicy = new FairshareSchedulingPolicy(this, "myFairsharePolicy");

fairsharePolicy.AddShare(new Share {
    ShareIdentifier = "A",
    WeightFactor = 1
});
fairsharePolicy.AddShare(new Share {
    ShareIdentifier = "B",
    WeightFactor = 1
});
new JobQueue(this, "JobQueue", new JobQueueProps {
    SchedulingPolicy = fairsharePolicy
});
```

Golang:

```go
fairsharePolicy := batch.NewFairshareSchedulingPolicy(this, jsii.String("myFairsharePolicy"))

fairsharePolicy.AddShare(&Share{
	ShareIdentifier: jsii.String("A"),
	WeightFactor: jsii.Number(1),
})
fairsharePolicy.AddShare(&Share{
	ShareIdentifier: jsii.String("B"),
	WeightFactor: jsii.Number(1),
})
batch.NewJobQueue(this, jsii.String("JobQueue"), &JobQueueProps{
	SchedulingPolicy: fairsharePolicy,
})
```

*Note*: The scheduler will only consider the current usage of the compute environment unless you specify `shareDecay`.
For example, a `shareDecay` of 5 minutes in the above example means that at any given point in time, twice as many `'A'` jobs
will be scheduled for each `'B'` job, but only for the past 5 minutes. If `'B'` jobs run longer than 5 minutes, then
the scheduler is allowed to put more than two `'A'` jobs for each `'B'` job, because the usage of those long-running
`'B'` jobs will no longer be considered after 5 minutes. `shareDecay` linearly decreases the usage of
long running jobs for calculation purposes. For example if share decay is 60 seconds,
then jobs that run for 30 seconds have their usage considered to be only 50% of what it actually is,
but after a whole minute the scheduler pretends they don't exist for fairness calculations.

The following code specifies a `shareDecay` of 5 minutes:

TypeScript:

```ts
const fairsharePolicy = new batch.FairshareSchedulingPolicy(this, 'myFairsharePolicy', {
   shareDecay: cdk.Duration.minutes(5),
});
```

Python:

```python
fairshare_policy = batch.FairshareSchedulingPolicy(self, "myFairsharePolicy",
    share_decay=cdk.Duration.minutes(5)
)
```

Java:

```java
FairshareSchedulingPolicy fairsharePolicy = FairshareSchedulingPolicy.Builder.create(this, "myFairsharePolicy")
        .shareDecay(Duration.minutes(5))
        .build();
```

C# / .NET:

```csharp
var fairsharePolicy = new FairshareSchedulingPolicy(this, "myFairsharePolicy", new FairshareSchedulingPolicyProps {
    ShareDecay = Duration.Minutes(5)
});
```

Golang:

```go
fairsharePolicy := batch.NewFairshareSchedulingPolicy(this, jsii.String("myFairsharePolicy"), &FairshareSchedulingPolicyProps{
	ShareDecay: cdk.Duration_Minutes(jsii.Number(5)),
})
```

If you have high priority jobs that should always be executed as soon as they arrive,
you can define a `computeReservation` to specify the percentage of the
maximum vCPU capacity that should be reserved for shares that are *not in the queue*.
The actual reserved percentage is defined by Batch as:

$$
 (\frac{computeReservation}{100}) ^ {ActiveFairShares}
$$

where `ActiveFairShares` is the number of shares for which there exists
at least one job in the queue with a unique share identifier.

This is best illustrated with an example.
Suppose there are three shares with share identifiers `A`, `B` and `C` respectively
and we specify the `computeReservation` to be 75%. The queue is currently empty,
and no other shares exist.

There are no active fair shares, since the queue is empty.
Thus (75/100)^0 = 1 = 100% of the maximum vCpus are reserved for all shares.

A job with identifier `A` enters the queue.

The number of active fair shares is now 1, hence
(75/100)^1 = .75 = 75% of the maximum vCpus are reserved for all shares that do not have the identifier `A`;
for this example, this is `B` and `C`,
(but if jobs are submitted with a share identifier not covered by this fairshare policy, those would be considered just as `B` and `C` are).

Now a `B` job enters the queue. The number of active fair shares is now 2,
so (75/100)^2 = .5625 = 56.25% of the maximum vCpus are reserved for all shares that do not have the identifier `A` or `B`.

Now a second `A` job enters the queue. The number of active fair shares is still 2,
so the percentage reserved is still 56.25%

Now a `C` job enters the queue. The number of active fair shares is now 3,
so (75/100)^3 = .421875 = 42.1875% of the maximum vCpus are reserved for all shares that do not have the identifier `A`, `B`, or `C`.

If there are no other shares that your jobs can specify, this means that 42.1875% of your capacity will never be used!

Now, `A`, `B`, and `C` can only consume 100% - 42.1875% = 57.8125% of the maximum vCpus.
Note that the this percentage is **not** split between `A`, `B`, and `C`.
Instead, the scheduler will use their `weightFactor`s to decide which jobs to schedule;
the only difference is that instead of competing for 100% of the max capacity, jobs compete for 57.8125% of the max capacity.

This example specifies a `computeReservation` of 75% that will behave as explained in the example above:

TypeScript:

```ts
new batch.FairshareSchedulingPolicy(this, 'myFairsharePolicy', {
  computeReservation: 75,
  shares: [
    { weightFactor: 1, shareIdentifier: 'A' },
    { weightFactor: 0.5, shareIdentifier: 'B' },
    { weightFactor: 2, shareIdentifier: 'C' },
  ],
});
```

Python:

```python
batch.FairshareSchedulingPolicy(self, "myFairsharePolicy",
    compute_reservation=75,
    shares=[batch.Share(weight_factor=1, share_identifier="A"), batch.Share(weight_factor=0.5, share_identifier="B"), batch.Share(weight_factor=2, share_identifier="C")
    ]
)
```

Java:

```java
FairshareSchedulingPolicy.Builder.create(this, "myFairsharePolicy")
        .computeReservation(75)
        .shares(List.of(Share.builder().weightFactor(1).shareIdentifier("A").build(), Share.builder().weightFactor(0.5).shareIdentifier("B").build(), Share.builder().weightFactor(2).shareIdentifier("C").build()))
        .build();
```

C# / .NET:

```csharp
new FairshareSchedulingPolicy(this, "myFairsharePolicy", new FairshareSchedulingPolicyProps {
    ComputeReservation = 75,
    Shares = new [] { new Share { WeightFactor = 1, ShareIdentifier = "A" }, new Share { WeightFactor = 0.5, ShareIdentifier = "B" }, new Share { WeightFactor = 2, ShareIdentifier = "C" } }
});
```

Golang:

```go
batch.NewFairshareSchedulingPolicy(this, jsii.String("myFairsharePolicy"), &FairshareSchedulingPolicyProps{
	ComputeReservation: jsii.Number(75),
	Shares: []Share{
		&Share{
			WeightFactor: jsii.Number(1),
			ShareIdentifier: jsii.String("A"),
		},
		&Share{
			WeightFactor: jsii.Number(0.5),
			ShareIdentifier: jsii.String("B"),
		},
		&Share{
			WeightFactor: jsii.Number(2),
			ShareIdentifier: jsii.String("C"),
		},
	},
})
```

You can specify a `priority` on your `JobDefinition`s to tell the scheduler to prioritize certain jobs that share the same share identifier.

### Configuring Job Retry Policies

Certain workflows may result in Jobs failing due to intermittent issues.
Jobs can specify retry policies to respond to different failures with different actions.
There are three different ways information about the way a Job exited can be conveyed;

* `exitCode`: the exit code returned from the process executed by the container. Will only match non-zero exit codes.
* `reason`: any middleware errors, like your Docker registry being down.
* `statusReason`: infrastructure errors, most commonly your spot instance being reclaimed.

For most use cases, only one of these will be associated with a particular action at a time.
To specify common `exitCode`s, `reason`s, or `statusReason`s, use the corresponding value from
the [`Reason`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Reason.html) class. This example shows some common failure reasons:

TypeScript:

```ts
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
   container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
  }),
  retryAttempts: 5,
  retryStrategies: [
    batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.CANNOT_PULL_CONTAINER),
  ],
});
jobDefn.addRetryStrategy(
  batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.SPOT_INSTANCE_RECLAIMED),
);
jobDefn.addRetryStrategy(
  batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.CANNOT_PULL_CONTAINER),
);
jobDefn.addRetryStrategy(
  batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.custom({
    onExitCode: '40*',
    onReason: 'some reason',
  })),
);
```

Python:

```python
job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256
    ),
    retry_attempts=5,
    retry_strategies=[
        batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.CANNOT_PULL_CONTAINER)
    ]
)
job_defn.add_retry_strategy(
    batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.SPOT_INSTANCE_RECLAIMED))
job_defn.add_retry_strategy(
    batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.CANNOT_PULL_CONTAINER))
job_defn.add_retry_strategy(
    batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.custom(
        on_exit_code="40*",
        on_reason="some reason"
    )))
```

Java:

```java
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .build())
        .retryAttempts(5)
        .retryStrategies(List.of(RetryStrategy.of(Action.EXIT, Reason.CANNOT_PULL_CONTAINER)))
        .build();
jobDefn.addRetryStrategy(RetryStrategy.of(Action.EXIT, Reason.SPOT_INSTANCE_RECLAIMED));
jobDefn.addRetryStrategy(RetryStrategy.of(Action.EXIT, Reason.CANNOT_PULL_CONTAINER));
jobDefn.addRetryStrategy(RetryStrategy.of(Action.EXIT, Reason.custom(CustomReason.builder()
        .onExitCode("40*")
        .onReason("some reason")
        .build())));
```

C# / .NET:

```csharp
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256
    }),
    RetryAttempts = 5,
    RetryStrategies = new [] { RetryStrategy.Of(Action.EXIT, Reason.CANNOT_PULL_CONTAINER) }
});
jobDefn.AddRetryStrategy(RetryStrategy.Of(Action.EXIT, Reason.SPOT_INSTANCE_RECLAIMED));
jobDefn.AddRetryStrategy(RetryStrategy.Of(Action.EXIT, Reason.CANNOT_PULL_CONTAINER));
jobDefn.AddRetryStrategy(RetryStrategy.Of(Action.EXIT, Reason.Custom(new CustomReason {
    OnExitCode = "40*",
    OnReason = "some reason"
})));
```

Golang:

```go
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("containerDefn"), &EcsEc2ContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
	}),
	RetryAttempts: jsii.Number(5),
	RetryStrategies: []RetryStrategy{
		batch.RetryStrategy_Of(batch.Action_EXIT, batch.Reason_CANNOT_PULL_CONTAINER()),
	},
})
jobDefn.addRetryStrategy(batch.RetryStrategy_Of(batch.Action_EXIT, batch.Reason_SPOT_INSTANCE_RECLAIMED()))
jobDefn.addRetryStrategy(batch.RetryStrategy_Of(batch.Action_EXIT, batch.Reason_CANNOT_PULL_CONTAINER()))
jobDefn.addRetryStrategy(batch.RetryStrategy_Of(batch.Action_EXIT, batch.Reason_Custom(&CustomReason{
	OnExitCode: jsii.String("40*"),
	OnReason: jsii.String("some reason"),
})))
```

When specifying a custom reason,
you can specify a glob string to match each of these and react to different failures accordingly.
Up to five different retry strategies can be configured for each Job,
and each strategy can match against some or all of `exitCode`, `reason`, and `statusReason`.
You can optionally configure the number of times a job will be retried,
but you cannot configure different retry counts for different strategies; they all share the same count.
If multiple conditions are specified in a given retry strategy,
they must all match for the action to be taken; the conditions are ANDed together, not ORed.

### Running single-container ECS workflows

Batch can run jobs on ECS or EKS. ECS jobs can be defined as single container or multinode.
This example creates a `JobDefinition` that runs a single container with ECS:

TypeScript:

```ts
declare const myFileSystem: efs.IFileSystem;
declare const myJobRole: iam.Role;
myFileSystem.grantRead(myJobRole);

const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
  container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
    volumes: [batch.EcsVolume.efs({
      name: 'myVolume',
      fileSystem: myFileSystem,
      containerPath: '/Volumes/myVolume',
      useJobRole: true,
    })],
    jobRole: myJobRole,
  }),
});
```

Python:

```python
# my_file_system: efs.IFileSystem
# my_job_role: iam.Role

my_file_system.grant_read(my_job_role)

job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256,
        volumes=[batch.EcsVolume.efs(
            name="myVolume",
            file_system=my_file_system,
            container_path="/Volumes/myVolume",
            use_job_role=True
        )],
        job_role=my_job_role
    )
)
```

Java:

```java
IFileSystem myFileSystem;
Role myJobRole;

myFileSystem.grantRead(myJobRole);

EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .volumes(List.of(EcsVolume.efs(EfsVolumeOptions.builder()
                        .name("myVolume")
                        .fileSystem(myFileSystem)
                        .containerPath("/Volumes/myVolume")
                        .useJobRole(true)
                        .build())))
                .jobRole(myJobRole)
                .build())
        .build();
```

C# / .NET:

```csharp
IFileSystem myFileSystem;
Role myJobRole;

myFileSystem.GrantRead(myJobRole);

var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256,
        Volumes = new [] { EcsVolume.Efs(new EfsVolumeOptions {
            Name = "myVolume",
            FileSystem = myFileSystem,
            ContainerPath = "/Volumes/myVolume",
            UseJobRole = true
        }) },
        JobRole = myJobRole
    })
});
```

Golang:

```go
var myFileSystem IFileSystem
var myJobRole Role

myFileSystem.GrantRead(myJobRole)

jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("containerDefn"), &EcsEc2ContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
		Volumes: []EcsVolume{
			batch.EcsVolume_Efs(&EfsVolumeOptions{
				Name: jsii.String("myVolume"),
				FileSystem: myFileSystem,
				ContainerPath: jsii.String("/Volumes/myVolume"),
				UseJobRole: jsii.Boolean(true),
			}),
		},
		JobRole: myJobRole,
	}),
})
```

For workflows that need persistent storage, batch supports mounting `Volume`s to the container.
You can both provision the volume and mount it to the container in a single operation:

TypeScript:

```ts
declare const myFileSystem: efs.IFileSystem;
declare const jobDefn: batch.EcsJobDefinition;

jobDefn.container.addVolume(batch.EcsVolume.efs({
  name: 'myVolume',
  fileSystem: myFileSystem,
  containerPath: '/Volumes/myVolume',
}));
```

Python:

```python
# my_file_system: efs.IFileSystem
# job_defn: batch.EcsJobDefinition

job_defn.container.add_volume(batch.EcsVolume.efs(
    name="myVolume",
    file_system=my_file_system,
    container_path="/Volumes/myVolume"
))
```

Java:

```java
IFileSystem myFileSystem;
EcsJobDefinition jobDefn;

jobDefn.container.addVolume(EcsVolume.efs(EfsVolumeOptions.builder()
        .name("myVolume")
        .fileSystem(myFileSystem)
        .containerPath("/Volumes/myVolume")
        .build()));
```

C# / .NET:

```csharp
IFileSystem myFileSystem;
EcsJobDefinition jobDefn;

jobDefn.Container.AddVolume(EcsVolume.Efs(new EfsVolumeOptions {
    Name = "myVolume",
    FileSystem = myFileSystem,
    ContainerPath = "/Volumes/myVolume"
}));
```

Golang:

```go
var myFileSystem IFileSystem
var jobDefn EcsJobDefinition

jobDefn.Container.AddVolume(batch.EcsVolume_Efs(&EfsVolumeOptions{
	Name: jsii.String("myVolume"),
	FileSystem: myFileSystem,
	ContainerPath: jsii.String("/Volumes/myVolume"),
}))
```

### Running an ECS workflow with Fargate container

TypeScript:

```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,
  }),
});
```

Python:

```python
job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsFargateContainerDefinition(self, "myFargateContainer",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256,
        ephemeral_storage_size=cdk.Size.gibibytes(100),
        fargate_cpu_architecture=ecs.CpuArchitecture.ARM64,
        fargate_operating_system_family=ecs.OperatingSystemFamily.LINUX
    )
)
```

Java:

```java
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsFargateContainerDefinition.Builder.create(this, "myFargateContainer")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .ephemeralStorageSize(Size.gibibytes(100))
                .fargateCpuArchitecture(CpuArchitecture.ARM64)
                .fargateOperatingSystemFamily(OperatingSystemFamily.LINUX)
                .build())
        .build();
```

C# / .NET:

```csharp
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsFargateContainerDefinition(this, "myFargateContainer", new EcsFargateContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256,
        EphemeralStorageSize = Size.Gibibytes(100),
        FargateCpuArchitecture = CpuArchitecture.ARM64,
        FargateOperatingSystemFamily = OperatingSystemFamily.LINUX
    })
});
```

Golang:

```go
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsFargateContainerDefinition(this, jsii.String("myFargateContainer"), &EcsFargateContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
		EphemeralStorageSize: cdk.Size_Gibibytes(jsii.Number(100)),
		FargateCpuArchitecture: ecs.CpuArchitecture_ARM64(),
		FargateOperatingSystemFamily: ecs.OperatingSystemFamily_LINUX(),
	}),
})
```

### Enable Execute Command (ECS Exec)

You can enable [ECS Exec](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html) for interactive debugging and troubleshooting by setting `enableExecuteCommand` to `true`.
When enabled, you'll be able to execute commands interactively in running containers.

TypeScript:

```ts
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
  container: new batch.EcsEc2ContainerDefinition(this, 'Ec2Container', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
    enableExecuteCommand: true, // Enable ECS Exec
  }),
});
```

Python:

```python
job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsEc2ContainerDefinition(self, "Ec2Container",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256,
        enable_execute_command=True
    )
)
```

Java:

```java
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsEc2ContainerDefinition.Builder.create(this, "Ec2Container")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .enableExecuteCommand(true)
                .build())
        .build();
```

C# / .NET:

```csharp
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsEc2ContainerDefinition(this, "Ec2Container", new EcsEc2ContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256,
        EnableExecuteCommand = true
    })
});
```

Golang:

```go
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("Ec2Container"), &EcsEc2ContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
		EnableExecuteCommand: jsii.Boolean(true),
	}),
})
```

The same functionality is available for Fargate containers:

TypeScript:

```ts
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
  container: new batch.EcsFargateContainerDefinition(this, 'FargateContainer', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
    enableExecuteCommand: true, // Enable ECS Exec for Fargate
  }),
});
```

Python:

```python
job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsFargateContainerDefinition(self, "FargateContainer",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256,
        enable_execute_command=True
    )
)
```

Java:

```java
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsFargateContainerDefinition.Builder.create(this, "FargateContainer")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .enableExecuteCommand(true)
                .build())
        .build();
```

C# / .NET:

```csharp
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsFargateContainerDefinition(this, "FargateContainer", new EcsFargateContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256,
        EnableExecuteCommand = true
    })
});
```

Golang:

```go
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsFargateContainerDefinition(this, jsii.String("FargateContainer"), &EcsFargateContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
		EnableExecuteCommand: jsii.Boolean(true),
	}),
})
```

When `enableExecuteCommand` is set to `true`:

- If no `jobRole` is provided, a new IAM role will be automatically created with the required SSM permissions
- If a `jobRole` is already provided, the necessary SSM permissions will be added to the existing role

### Secrets

You can expose SecretsManager Secret ARNs or SSM Parameters to your container as environment variables.
The following example defines the `MY_SECRET_ENV_VAR` environment variable that contains the
ARN of the Secret defined by `mySecret`:

TypeScript:

```ts
declare const mySecret: secretsmanager.ISecret;

const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
  container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
    secrets: {
      MY_SECRET_ENV_VAR: batch.Secret.fromSecretsManager(mySecret),
    }
  }),
});
```

Python:

```python
# my_secret: secretsmanager.ISecret

job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256,
        secrets={
            "MY_SECRET_ENV_VAR": batch.Secret.from_secrets_manager(my_secret)
        }
    )
)
```

Java:

```java
ISecret mySecret;

EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .secrets(Map.of(
                        "MY_SECRET_ENV_VAR", Secret.fromSecretsManager(mySecret)))
                .build())
        .build();
```

C# / .NET:

```csharp
ISecret mySecret;

var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256,
        Secrets = new Dictionary<string, Secret> {
            { "MY_SECRET_ENV_VAR", Secret.FromSecretsManager(mySecret) }
        }
    })
});
```

Golang:

```go
var mySecret ISecret

jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("containerDefn"), &EcsEc2ContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
		Secrets: map[string]Secret{
			"MY_SECRET_ENV_VAR": batch.Secret_fromSecretsManager(mySecret),
		},
	}),
})
```

### Running Kubernetes Workflows

Batch also supports running workflows on EKS. The following example creates a `JobDefinition` that runs on EKS:

TypeScript:

```ts
const jobDefn = new batch.EksJobDefinition(this, 'eksf2', {
  container: new batch.EksContainerDefinition(this, 'container', {
    image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
    volumes: [batch.EksVolume.emptyDir({
      name: 'myEmptyDirVolume',
      mountPath: '/mount/path',
      medium: batch.EmptyDirMediumType.MEMORY,
      readonly: true,
      sizeLimit: cdk.Size.mebibytes(2048),
    })],
  }),
});
```

Python:

```python
job_defn = batch.EksJobDefinition(self, "eksf2",
    container=batch.EksContainerDefinition(self, "container",
        image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
        volumes=[batch.EksVolume.empty_dir(
            name="myEmptyDirVolume",
            mount_path="/mount/path",
            medium=batch.EmptyDirMediumType.MEMORY,
            readonly=True,
            size_limit=cdk.Size.mebibytes(2048)
        )]
    )
)
```

Java:

```java
EksJobDefinition jobDefn = EksJobDefinition.Builder.create(this, "eksf2")
        .container(EksContainerDefinition.Builder.create(this, "container")
                .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
                .volumes(List.of(EksVolume.emptyDir(EmptyDirVolumeOptions.builder()
                        .name("myEmptyDirVolume")
                        .mountPath("/mount/path")
                        .medium(EmptyDirMediumType.MEMORY)
                        .readonly(true)
                        .sizeLimit(Size.mebibytes(2048))
                        .build())))
                .build())
        .build();
```

C# / .NET:

```csharp
var jobDefn = new EksJobDefinition(this, "eksf2", new EksJobDefinitionProps {
    Container = new EksContainerDefinition(this, "container", new EksContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
        Volumes = new [] { EksVolume.EmptyDir(new EmptyDirVolumeOptions {
            Name = "myEmptyDirVolume",
            MountPath = "/mount/path",
            Medium = EmptyDirMediumType.MEMORY,
            Readonly = true,
            SizeLimit = Size.Mebibytes(2048)
        }) }
    })
});
```

Golang:

```go
jobDefn := batch.NewEksJobDefinition(this, jsii.String("eksf2"), &EksJobDefinitionProps{
	Container: batch.NewEksContainerDefinition(this, jsii.String("container"), &EksContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("amazon/amazon-ecs-sample")),
		Volumes: []EksVolume{
			batch.EksVolume_EmptyDir(&EmptyDirVolumeOptions{
				Name: jsii.String("myEmptyDirVolume"),
				MountPath: jsii.String("/mount/path"),
				Medium: batch.EmptyDirMediumType_MEMORY,
				Readonly: jsii.Boolean(true),
				SizeLimit: cdk.Size_Mebibytes(jsii.Number(2048)),
			}),
		},
	}),
})
```

You can mount `Volume`s to these containers in a single operation:

TypeScript:

```ts
declare const jobDefn: batch.EksJobDefinition;
jobDefn.container.addVolume(batch.EksVolume.emptyDir({
  name: 'emptyDir',
  mountPath: '/Volumes/emptyDir',
}));
jobDefn.container.addVolume(batch.EksVolume.hostPath({
  name: 'hostPath',
  hostPath: '/sys',
  mountPath: '/Volumes/hostPath',
}));
jobDefn.container.addVolume(batch.EksVolume.secret({
  name: 'secret',
  optional: true,
  mountPath: '/Volumes/secret',
  secretName: 'mySecret',
}));
```

Python:

```python
# job_defn: batch.EksJobDefinition

job_defn.container.add_volume(batch.EksVolume.empty_dir(
    name="emptyDir",
    mount_path="/Volumes/emptyDir"
))
job_defn.container.add_volume(batch.EksVolume.host_path(
    name="hostPath",
    host_path="/sys",
    mount_path="/Volumes/hostPath"
))
job_defn.container.add_volume(batch.EksVolume.secret(
    name="secret",
    optional=True,
    mount_path="/Volumes/secret",
    secret_name="mySecret"
))
```

Java:

```java
EksJobDefinition jobDefn;

jobDefn.container.addVolume(EksVolume.emptyDir(EmptyDirVolumeOptions.builder()
        .name("emptyDir")
        .mountPath("/Volumes/emptyDir")
        .build()));
jobDefn.container.addVolume(EksVolume.hostPath(HostPathVolumeOptions.builder()
        .name("hostPath")
        .hostPath("/sys")
        .mountPath("/Volumes/hostPath")
        .build()));
jobDefn.container.addVolume(EksVolume.secret(SecretPathVolumeOptions.builder()
        .name("secret")
        .optional(true)
        .mountPath("/Volumes/secret")
        .secretName("mySecret")
        .build()));
```

C# / .NET:

```csharp
EksJobDefinition jobDefn;

jobDefn.Container.AddVolume(EksVolume.EmptyDir(new EmptyDirVolumeOptions {
    Name = "emptyDir",
    MountPath = "/Volumes/emptyDir"
}));
jobDefn.Container.AddVolume(EksVolume.HostPath(new HostPathVolumeOptions {
    Name = "hostPath",
    HostPath = "/sys",
    MountPath = "/Volumes/hostPath"
}));
jobDefn.Container.AddVolume(EksVolume.Secret(new SecretPathVolumeOptions {
    Name = "secret",
    Optional = true,
    MountPath = "/Volumes/secret",
    SecretName = "mySecret"
}));
```

Golang:

```go
var jobDefn EksJobDefinition

jobDefn.Container.AddVolume(batch.EksVolume_EmptyDir(&EmptyDirVolumeOptions{
	Name: jsii.String("emptyDir"),
	MountPath: jsii.String("/Volumes/emptyDir"),
}))
jobDefn.Container.AddVolume(batch.EksVolume_HostPath(&HostPathVolumeOptions{
	Name: jsii.String("hostPath"),
	HostPath: jsii.String("/sys"),
	MountPath: jsii.String("/Volumes/hostPath"),
}))
jobDefn.Container.AddVolume(batch.EksVolume_Secret(&SecretPathVolumeOptions{
	Name: jsii.String("secret"),
	Optional: jsii.Boolean(true),
	MountPath: jsii.String("/Volumes/secret"),
	SecretName: jsii.String("mySecret"),
}))
```

### Running Distributed Workflows

Some workflows benefit from parallellization and are most powerful when run in a distributed environment,
such as certain numerical calculations or simulations. Batch offers `MultiNodeJobDefinition`s,
which allow a single job to run on multiple instances in parallel, for this purpose.
Message Passing Interface (MPI) is often used with these workflows.
You must configure your containers to use MPI properly,
but Batch allows different nodes running different containers to communicate easily with one another.
You must configure your containers to use certain environment variables that Batch will provide them,
which lets them know which one is the main node, among other information.
For an in-depth example on using MPI to perform numerical computations on Batch,
see this [blog post](https://aws.amazon.com/blogs/compute/building-a-tightly-coupled-molecular-dynamics-workflow-with-multi-node-parallel-jobs-in-aws-batch/)
In particular, the environment variable that tells the containers which one is the main node can be configured on your [`MultiNodeJobDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.MultiNodeJobDefinition.html) as follows:

TypeScript:

```ts
const multiNodeJob = new batch.MultiNodeJobDefinition(this, 'JobDefinition', {
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.R4, ec2.InstanceSize.LARGE), // optional, omit to let Batch choose the type for you
  containers: [{
    container: new batch.EcsEc2ContainerDefinition(this, 'mainMPIContainer', {
      image: ecs.ContainerImage.fromRegistry('yourregsitry.com/yourMPIImage:latest'),
      cpu: 256,
      memory: cdk.Size.mebibytes(2048),
    }),
    startNode: 0,
    endNode: 5,
  }],
});
// convenience method
multiNodeJob.addContainer({
  startNode: 6,
  endNode: 10,
  container: new batch.EcsEc2ContainerDefinition(this, 'multiContainer', {
    image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
    cpu: 256,
    memory: cdk.Size.mebibytes(2048),
  }),
});
```

Python:

```python
multi_node_job = batch.MultiNodeJobDefinition(self, "JobDefinition",
    instance_type=ec2.InstanceType.of(ec2.InstanceClass.R4, ec2.InstanceSize.LARGE),  # optional, omit to let Batch choose the type for you
    containers=[batch.MultiNodeContainer(
        container=batch.EcsEc2ContainerDefinition(self, "mainMPIContainer",
            image=ecs.ContainerImage.from_registry("yourregsitry.com/yourMPIImage:latest"),
            cpu=256,
            memory=cdk.Size.mebibytes(2048)
        ),
        start_node=0,
        end_node=5
    )]
)
# convenience method
multi_node_job.add_container(
    start_node=6,
    end_node=10,
    container=batch.EcsEc2ContainerDefinition(self, "multiContainer",
        image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
        cpu=256,
        memory=cdk.Size.mebibytes(2048)
    )
)
```

Java:

```java
MultiNodeJobDefinition multiNodeJob = MultiNodeJobDefinition.Builder.create(this, "JobDefinition")
        .instanceType(InstanceType.of(InstanceClass.R4, InstanceSize.LARGE)) // optional, omit to let Batch choose the type for you
        .containers(List.of(MultiNodeContainer.builder()
                .container(EcsEc2ContainerDefinition.Builder.create(this, "mainMPIContainer")
                        .image(ContainerImage.fromRegistry("yourregsitry.com/yourMPIImage:latest"))
                        .cpu(256)
                        .memory(Size.mebibytes(2048))
                        .build())
                .startNode(0)
                .endNode(5)
                .build()))
        .build();
// convenience method
multiNodeJob.addContainer(MultiNodeContainer.builder()
        .startNode(6)
        .endNode(10)
        .container(EcsEc2ContainerDefinition.Builder.create(this, "multiContainer")
                .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
                .cpu(256)
                .memory(Size.mebibytes(2048))
                .build())
        .build());
```

C# / .NET:

```csharp
var multiNodeJob = new MultiNodeJobDefinition(this, "JobDefinition", new MultiNodeJobDefinitionProps {
    InstanceType = InstanceType.Of(InstanceClass.R4, InstanceSize.LARGE),  // optional, omit to let Batch choose the type for you
    Containers = new [] { new MultiNodeContainer {
        Container = new EcsEc2ContainerDefinition(this, "mainMPIContainer", new EcsEc2ContainerDefinitionProps {
            Image = ContainerImage.FromRegistry("yourregsitry.com/yourMPIImage:latest"),
            Cpu = 256,
            Memory = Size.Mebibytes(2048)
        }),
        StartNode = 0,
        EndNode = 5
    } }
});
// convenience method
multiNodeJob.AddContainer(new MultiNodeContainer {
    StartNode = 6,
    EndNode = 10,
    Container = new EcsEc2ContainerDefinition(this, "multiContainer", new EcsEc2ContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
        Cpu = 256,
        Memory = Size.Mebibytes(2048)
    })
});
```

Golang:

```go
multiNodeJob := batch.NewMultiNodeJobDefinition(this, jsii.String("JobDefinition"), &MultiNodeJobDefinitionProps{
	InstanceType: ec2.InstanceType_Of(ec2.InstanceClass_R4, ec2.InstanceSize_LARGE),
	 // optional, omit to let Batch choose the type for you
	Containers: []MultiNodeContainer{
		&MultiNodeContainer{
			Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("mainMPIContainer"), &EcsEc2ContainerDefinitionProps{
				Image: ecs.ContainerImage_FromRegistry(jsii.String("yourregsitry.com/yourMPIImage:latest")),
				Cpu: jsii.Number(256),
				Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
			}),
			StartNode: jsii.Number(0),
			EndNode: jsii.Number(5),
		},
	},
})
// convenience method
multiNodeJob.AddContainer(&MultiNodeContainer{
	StartNode: jsii.Number(6),
	EndNode: jsii.Number(10),
	Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("multiContainer"), &EcsEc2ContainerDefinitionProps{
		Image: ecs.ContainerImage_*FromRegistry(jsii.String("amazon/amazon-ecs-sample")),
		Cpu: jsii.Number(256),
		Memory: cdk.Size_*Mebibytes(jsii.Number(2048)),
	}),
})
```

If you need to set the control node to an index other than 0, specify it in directly:

TypeScript:

```ts
const multiNodeJob = new batch.MultiNodeJobDefinition(this, 'JobDefinition', {
  mainNode: 5,
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.R4, ec2.InstanceSize.LARGE),
});
```

Python:

```python
multi_node_job = batch.MultiNodeJobDefinition(self, "JobDefinition",
    main_node=5,
    instance_type=ec2.InstanceType.of(ec2.InstanceClass.R4, ec2.InstanceSize.LARGE)
)
```

Java:

```java
MultiNodeJobDefinition multiNodeJob = MultiNodeJobDefinition.Builder.create(this, "JobDefinition")
        .mainNode(5)
        .instanceType(InstanceType.of(InstanceClass.R4, InstanceSize.LARGE))
        .build();
```

C# / .NET:

```csharp
var multiNodeJob = new MultiNodeJobDefinition(this, "JobDefinition", new MultiNodeJobDefinitionProps {
    MainNode = 5,
    InstanceType = InstanceType.Of(InstanceClass.R4, InstanceSize.LARGE)
});
```

Golang:

```go
multiNodeJob := batch.NewMultiNodeJobDefinition(this, jsii.String("JobDefinition"), &MultiNodeJobDefinitionProps{
	MainNode: jsii.Number(5),
	InstanceType: ec2.InstanceType_Of(ec2.InstanceClass_R4, ec2.InstanceSize_LARGE),
})
```

### Pass Parameters to a Job

Batch allows you define parameters in your `JobDefinition`, which can be referenced in the container command. For example:

TypeScript:

```ts
new batch.EcsJobDefinition(this, 'JobDefn', {
  parameters: { echoParam: 'foobar' },
  container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
    command: [
      'echo',
      'Ref::echoParam',
    ],
  }),
});
```

Python:

```python
batch.EcsJobDefinition(self, "JobDefn",
    parameters={"echo_param": "foobar"},
    container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256,
        command=["echo", "Ref::echoParam"
        ]
    )
)
```

Java:

```java
EcsJobDefinition.Builder.create(this, "JobDefn")
        .parameters(Map.of("echoParam", "foobar"))
        .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .command(List.of("echo", "Ref::echoParam"))
                .build())
        .build();
```

C# / .NET:

```csharp
new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Parameters = new Dictionary<string, object> { { "echoParam", "foobar" } },
    Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256,
        Command = new [] { "echo", "Ref::echoParam" }
    })
});
```

Golang:

```go
batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Parameters: map[string]interface{}{
		"echoParam": jsii.String("foobar"),
	},
	Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("containerDefn"), &EcsEc2ContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
		Command: []*string{
			jsii.String("echo"),
			jsii.String("Ref::echoParam"),
		},
	}),
})
```

### Job Definition Version Management

By default, when you update a Job Definition, AWS Batch automatically deregisters the previous revision.
This means any jobs that were submitted using the old revision may fail if they haven't started yet.

You can preserve previous revisions by setting `skipDeregisterOnUpdate` to `true`:

TypeScript:

```ts
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
  container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
  }),
  skipDeregisterOnUpdate: true,  // Keep previous revisions active
});
```

Python:

```python
job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256
    ),
    skip_deregister_on_update=True
)
```

Java:

```java
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .build())
        .skipDeregisterOnUpdate(true)
        .build();
```

C# / .NET:

```csharp
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256
    }),
    SkipDeregisterOnUpdate = true
});
```

Golang:

```go
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("containerDefn"), &EcsEc2ContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
	}),
	SkipDeregisterOnUpdate: jsii.Boolean(true),
})
```

* This applies to all Job Definition types: ECS (EC2 and Fargate), EKS, and MultiNode
* Default behavior (when not specified) follows AWS Batch defaults: previous revisions are deregistered

### Understanding Progressive Allocation Strategies

AWS Batch uses an [allocation strategy](https://docs.aws.amazon.com/batch/latest/userguide/allocation-strategies.html) to determine what compute resource will efficiently handle incoming job requests. By default, **BEST_FIT** will pick an available compute instance based on vCPU requirements. If none exist, the job will wait until resources become available. However, with this strategy, you may have jobs waiting in the queue unnecessarily despite having more powerful instances available. Below is an example of how that situation might look like:

```plaintext
Compute Environment:

1. m5.xlarge => 4 vCPU
2. m5.2xlarge => 8 vCPU
```

```plaintext
Job Queue:
---------
| A | B |
---------

Job Requirements:
A => 4 vCPU - ALLOCATED TO m5.xlarge
B => 2 vCPU - WAITING
```

In this situation, Batch will allocate **Job A** to compute resource #1 because it is the most cost efficient resource that matches the vCPU requirement. However, with this `BEST_FIT` strategy, **Job B** will not be allocated to our other available compute resource even though it is strong enough to handle it. Instead, it will wait until the first job is finished processing or wait a similar `m5.xlarge` resource to be provisioned.

The alternative would be to use the `BEST_FIT_PROGRESSIVE` strategy in order for the remaining job to be handled in larger containers regardless of vCPU requirement and costs.

### Permissions

You can grant any Principal the `batch:submitJob` permission on both a job definition and a job queue like this:

TypeScript:

```ts
declare const vpc: ec2.IVpc;

const ecsJob = new batch.EcsJobDefinition(this, 'JobDefn', {
  container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
  }),
});

const queue = new batch.JobQueue(this, 'JobQueue', {
  computeEnvironments: [{
    computeEnvironment: new batch.ManagedEc2EcsComputeEnvironment(this, 'managedEc2CE', {
      vpc,
    }),
    order: 1,
  }],
  priority: 10,
});

const user = new iam.User(this, 'MyUser');
ecsJob.grantSubmitJob(user, queue);
```

Python:

```python
# vpc: ec2.IVpc

ecs_job = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256
    )
)

queue = batch.JobQueue(self, "JobQueue",
    compute_environments=[batch.OrderedComputeEnvironment(
        compute_environment=batch.ManagedEc2EcsComputeEnvironment(self, "managedEc2CE",
            vpc=vpc
        ),
        order=1
    )],
    priority=10
)

user = iam.User(self, "MyUser")
ecs_job.grant_submit_job(user, queue)
```

Java:

```java
IVpc vpc;

EcsJobDefinition ecsJob = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .build())
        .build();

JobQueue queue = JobQueue.Builder.create(this, "JobQueue")
        .computeEnvironments(List.of(OrderedComputeEnvironment.builder()
                .computeEnvironment(ManagedEc2EcsComputeEnvironment.Builder.create(this, "managedEc2CE")
                        .vpc(vpc)
                        .build())
                .order(1)
                .build()))
        .priority(10)
        .build();

User user = new User(this, "MyUser");
ecsJob.grantSubmitJob(user, queue);
```

C# / .NET:

```csharp
IVpc vpc;

var ecsJob = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256
    })
});

var queue = new JobQueue(this, "JobQueue", new JobQueueProps {
    ComputeEnvironments = new [] { new OrderedComputeEnvironment {
        ComputeEnvironment = new ManagedEc2EcsComputeEnvironment(this, "managedEc2CE", new ManagedEc2EcsComputeEnvironmentProps {
            Vpc = vpc
        }),
        Order = 1
    } },
    Priority = 10
});

var user = new User(this, "MyUser");
ecsJob.GrantSubmitJob(user, queue);
```

Golang:

```go
var vpc IVpc

ecsJob := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsEc2ContainerDefinition(this, jsii.String("containerDefn"), &EcsEc2ContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
	}),
})

queue := batch.NewJobQueue(this, jsii.String("JobQueue"), &JobQueueProps{
	ComputeEnvironments: []OrderedComputeEnvironment{
		&OrderedComputeEnvironment{
			ComputeEnvironment: batch.NewManagedEc2EcsComputeEnvironment(this, jsii.String("managedEc2CE"), &ManagedEc2EcsComputeEnvironmentProps{
				Vpc: *Vpc,
			}),
			Order: jsii.Number(1),
		},
	},
	Priority: jsii.Number(10),
})

user := iam.NewUser(this, jsii.String("MyUser"))
ecsJob.GrantSubmitJob(user, queue)
```

### Managing Consumable Resources

Consumable resources are finite resources that are consumed by jobs, such as third-party software licenses or API rate limits. AWS Batch tracks the usage of these resources and ensures that jobs only run when the required resources are available.

There are two types of consumable resources:

* **REPLENISHABLE**: Resources that can be re-used after a job completes (e.g., software licenses)
* **NON_REPLENISHABLE**: Resources that cannot be re-used after a job completes (e.g., API rate limits)

#### Creating Consumable Resources

You can create consumable resources to track and manage finite resources in your Batch workflows:

TypeScript:

```ts
// Create a replenishable consumable resource (e.g., software licenses)
const licenseResource = new batch.ConsumableResource(this, 'LicenseResource', {
  consumableResourceName: 'my-software-license',
  resourceType: batch.ConsumableResourceType.REPLENISHABLE,
  totalQuantity: 100,
});

// Create a non-replenishable consumable resource (e.g., API rate limits)
const apiRateLimitResource = new batch.ConsumableResource(this, 'ApiRateLimitResource', {
  consumableResourceName: 'api-rate-limit',
  resourceType: batch.ConsumableResourceType.NON_REPLENISHABLE,
  totalQuantity: 1000,
});
```

Python:

```python
# Create a replenishable consumable resource (e.g., software licenses)
license_resource = batch.ConsumableResource(self, "LicenseResource",
    consumable_resource_name="my-software-license",
    resource_type=batch.ConsumableResourceType.REPLENISHABLE,
    total_quantity=100
)

# Create a non-replenishable consumable resource (e.g., API rate limits)
api_rate_limit_resource = batch.ConsumableResource(self, "ApiRateLimitResource",
    consumable_resource_name="api-rate-limit",
    resource_type=batch.ConsumableResourceType.NON_REPLENISHABLE,
    total_quantity=1000
)
```

Java:

```java
// Create a replenishable consumable resource (e.g., software licenses)
ConsumableResource licenseResource = ConsumableResource.Builder.create(this, "LicenseResource")
        .consumableResourceName("my-software-license")
        .resourceType(ConsumableResourceType.REPLENISHABLE)
        .totalQuantity(100)
        .build();

// Create a non-replenishable consumable resource (e.g., API rate limits)
ConsumableResource apiRateLimitResource = ConsumableResource.Builder.create(this, "ApiRateLimitResource")
        .consumableResourceName("api-rate-limit")
        .resourceType(ConsumableResourceType.NON_REPLENISHABLE)
        .totalQuantity(1000)
        .build();
```

C# / .NET:

```csharp
// Create a replenishable consumable resource (e.g., software licenses)
var licenseResource = new ConsumableResource(this, "LicenseResource", new ConsumableResourceProps {
    ConsumableResourceName = "my-software-license",
    ResourceType = ConsumableResourceType.REPLENISHABLE,
    TotalQuantity = 100
});

// Create a non-replenishable consumable resource (e.g., API rate limits)
var apiRateLimitResource = new ConsumableResource(this, "ApiRateLimitResource", new ConsumableResourceProps {
    ConsumableResourceName = "api-rate-limit",
    ResourceType = ConsumableResourceType.NON_REPLENISHABLE,
    TotalQuantity = 1000
});
```

Golang:

```go
// Create a replenishable consumable resource (e.g., software licenses)
licenseResource := batch.NewConsumableResource(this, jsii.String("LicenseResource"), &ConsumableResourceProps{
	ConsumableResourceName: jsii.String("my-software-license"),
	ResourceType: batch.ConsumableResourceType_REPLENISHABLE,
	TotalQuantity: jsii.Number(100),
})

// Create a non-replenishable consumable resource (e.g., API rate limits)
apiRateLimitResource := batch.NewConsumableResource(this, jsii.String("ApiRateLimitResource"), &ConsumableResourceProps{
	ConsumableResourceName: jsii.String("api-rate-limit"),
	ResourceType: batch.ConsumableResourceType_NON_REPLENISHABLE,
	TotalQuantity: jsii.Number(1000),
})
```

`resourceType` defaults to `REPLENISHABLE`, matching the AWS Batch API, and `totalQuantity` must be
a non-negative integer. Both `consumableResourceName` and `resourceType` replace the resource when
changed, so changing the type of a resource that has an explicit name also requires a new name.

Tags can be passed directly to the resource:

TypeScript:

```ts
const taggedResource = new batch.ConsumableResource(this, 'TaggedResource', {
  totalQuantity: 100,
  tags: {
    Team: 'batch',
  },
});
```

Python:

```python
tagged_resource = batch.ConsumableResource(self, "TaggedResource",
    total_quantity=100,
    tags={
        "Team": "batch"
    }
)
```

Java:

```java
ConsumableResource taggedResource = ConsumableResource.Builder.create(this, "TaggedResource")
        .totalQuantity(100)
        .tags(Map.of(
                "Team", "batch"))
        .build();
```

C# / .NET:

```csharp
var taggedResource = new ConsumableResource(this, "TaggedResource", new ConsumableResourceProps {
    TotalQuantity = 100,
    Tags = new Dictionary<string, string> {
        { "Team", "batch" }
    }
});
```

Golang:

```go
taggedResource := batch.NewConsumableResource(this, jsii.String("TaggedResource"), &ConsumableResourceProps{
	TotalQuantity: jsii.Number(100),
	Tags: map[string]*string{
		"Team": jsii.String("batch"),
	},
})
```

#### Granting Access to Consumable Resources

Use the `grants` property to give an identity permission to inspect or update a consumable resource:

TypeScript:

```ts
const licenseResource = new batch.ConsumableResource(this, 'LicenseResource', {
  totalQuantity: 100,
});

const user = new iam.User(this, 'MyUser');

// Describe the resource and list the jobs that use it
licenseResource.grants.read(user);

// Change the total quantity, e.g. to replenish a NON_REPLENISHABLE pool
licenseResource.grants.update(user);
```

Python:

```python
license_resource = batch.ConsumableResource(self, "LicenseResource",
    total_quantity=100
)

user = iam.User(self, "MyUser")

# Describe the resource and list the jobs that use it
license_resource.grants.read(user)

# Change the total quantity, e.g. to replenish a NON_REPLENISHABLE pool
license_resource.grants.update(user)
```

Java:

```java
ConsumableResource licenseResource = ConsumableResource.Builder.create(this, "LicenseResource")
        .totalQuantity(100)
        .build();

User user = new User(this, "MyUser");

// Describe the resource and list the jobs that use it
licenseResource.grants.read(user);

// Change the total quantity, e.g. to replenish a NON_REPLENISHABLE pool
licenseResource.grants.update(user);
```

C# / .NET:

```csharp
var licenseResource = new ConsumableResource(this, "LicenseResource", new ConsumableResourceProps {
    TotalQuantity = 100
});

var user = new User(this, "MyUser");

// Describe the resource and list the jobs that use it
licenseResource.Grants.Read(user);

// Change the total quantity, e.g. to replenish a NON_REPLENISHABLE pool
licenseResource.Grants.Update(user);
```

Golang:

```go
licenseResource := batch.NewConsumableResource(this, jsii.String("LicenseResource"), &ConsumableResourceProps{
	TotalQuantity: jsii.Number(100),
})

user := iam.NewUser(this, jsii.String("MyUser"))

// Describe the resource and list the jobs that use it
licenseResource.grants.Read(user)

// Change the total quantity, e.g. to replenish a NON_REPLENISHABLE pool
licenseResource.grants.Update(user)
```

#### Importing Existing Consumable Resources

You can import existing consumable resources by their ARN:

TypeScript:

```ts
const importedResource = batch.ConsumableResource.fromConsumableResourceArn(
  this,
  'ImportedResource',
  'arn:aws:batch:us-east-1:123456789012:consumable-resource/my-resource'
);
```

Python:

```python
imported_resource = batch.ConsumableResource.from_consumable_resource_arn(self, "ImportedResource", "arn:aws:batch:us-east-1:123456789012:consumable-resource/my-resource")
```

Java:

```java
IConsumableResource importedResource = ConsumableResource.fromConsumableResourceArn(this, "ImportedResource", "arn:aws:batch:us-east-1:123456789012:consumable-resource/my-resource");
```

C# / .NET:

```csharp
var importedResource = ConsumableResource.FromConsumableResourceArn(this, "ImportedResource", "arn:aws:batch:us-east-1:123456789012:consumable-resource/my-resource");
```

Golang:

```go
importedResource := batch.ConsumableResource_FromConsumableResourceArn(this, jsii.String("ImportedResource"), jsii.String("arn:aws:batch:us-east-1:123456789012:consumable-resource/my-resource"))
```

## Types

### Constructs (L2)

- [`ConsumableResource`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ConsumableResource.html) Construct (L2) A Batch Consumable Resource.
- [`EcsJobDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsJobDefinition.html) Construct (L2) A JobDefinition that uses ECS orchestration.
- [`EksJobDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EksJobDefinition.html) Construct (L2) A JobDefinition that uses Eks orchestration.
- [`FairshareSchedulingPolicy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.FairshareSchedulingPolicy.html) Construct (L2) Represents a Fairshare Scheduling Policy. Instructs the scheduler to allocate ComputeEnvironment vCPUs based on Job shareIdentifiers.
- [`FargateComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.FargateComputeEnvironment.html) Construct (L2) A ManagedComputeEnvironment that uses ECS orchestration on Fargate instances.
- [`JobQueue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobQueue.html) Construct (L2) JobQueues can receive Jobs, which are removed from the queue when sent to the linked ComputeEnvironment(s) to be executed.
- [`ManagedEc2EcsComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ManagedEc2EcsComputeEnvironment.html) Construct (L2) A ManagedComputeEnvironment that uses ECS orchestration on EC2 instances.
- [`ManagedEc2EksComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ManagedEc2EksComputeEnvironment.html) Construct (L2) A ManagedComputeEnvironment that uses ECS orchestration on EC2 instances.
- [`MultiNodeJobDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.MultiNodeJobDefinition.html) Construct (L2) A JobDefinition that uses Ecs orchestration to run multiple containers.
- [`UnmanagedComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.UnmanagedComputeEnvironment.html) Construct (L2) Unmanaged ComputeEnvironments do not provision or manage EC2 instances on your behalf.

### Constructs (L1)

- [`CfnComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.html) Construct (L1) The `AWS::Batch::ComputeEnvironment` resource defines your AWS Batch compute environment.
- [`CfnConsumableResource`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnConsumableResource.html) Construct (L1) The `AWS::Batch::ConsumableResource` resource specifies the parameters for an AWS Batch consumable resource.
- [`CfnJobDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.html) Construct (L1) The `AWS::Batch::JobDefinition` resource specifies the parameters for an AWS Batch job definition.
- [`CfnJobQueue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobQueue.html) Construct (L1) The `AWS::Batch::JobQueue` resource specifies the parameters for an AWS Batch job queue definition.
- [`CfnQuotaShare`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnQuotaShare.html) Construct (L1) Creates an AWS Batch quota share.
- [`CfnSchedulingPolicy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnSchedulingPolicy.html) Construct (L1) The `AWS::Batch::SchedulingPolicy` resource specifies the parameters for an AWS Batch scheduling policy.
- [`CfnServiceEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnServiceEnvironment.html) Construct (L1) Creates a service environment for running service jobs.

### Enums

- [`Action`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Action.html) Enum The Action to take when all specified conditions in a RetryStrategy are met.
- [`AllocationStrategy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.AllocationStrategy.html) Enum Determines how this compute environment chooses instances to spawn.
- [`ConsumableResourceType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ConsumableResourceType.html) Enum The type of consumable resource.
- [`DefaultInstanceClass`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.DefaultInstanceClass.html) Enum Batch default instances types.
- [`DevicePermission`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.DevicePermission.html) Enum Permissions for device access.
- [`DnsPolicy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.DnsPolicy.html) Enum The DNS Policy for the pod used by the Job Definition.
- [`EcsMachineImageType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsMachineImageType.html) Enum Maps the image to instance types.
- [`EksMachineImageType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EksMachineImageType.html) Enum Maps the image to instance types.
- [`EmptyDirMediumType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EmptyDirMediumType.html) Enum What medium the volume will live in.
- [`ImagePullPolicy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ImagePullPolicy.html) Enum Determines when the image is pulled from the registry to launch a container.
- [`JobStateTimeLimitActionsAction`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobStateTimeLimitActionsAction.html) Enum The action to take when a job is at the head of the job queue in the specified state for the specified period of time.
- [`JobStateTimeLimitActionsReason`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobStateTimeLimitActionsReason.html) Enum The reason to log for the action being taken.
- [`JobStateTimeLimitActionsState`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobStateTimeLimitActionsState.html) Enum The state of the job needed to trigger the action.
- [`TmpfsMountOption`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.TmpfsMountOption.html) Enum The supported options for a tmpfs mount for a container.
- [`UlimitName`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.UlimitName.html) Enum The resources to be limited.

### Structs

- [`CfnComputeEnvironment.CapacityReservationsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.CapacityReservationsProperty.html) Struct
- [`CfnComputeEnvironment.ComputeResourcesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.ComputeResourcesProperty.html) Struct Details about the compute resources managed by the compute environment.
- [`CfnComputeEnvironment.ComputeScalingPolicyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.ComputeScalingPolicyProperty.html) Struct
- [`CfnComputeEnvironment.Ec2ConfigurationObjectProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.Ec2ConfigurationObjectProperty.html) Struct Provides information used to select Amazon Machine Images (AMIs) for instances in the compute environment.
- [`CfnComputeEnvironment.EcsSettingsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.EcsSettingsProperty.html) Struct
- [`CfnComputeEnvironment.EksAccessEntryProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.EksAccessEntryProperty.html) Struct The EKS access entry configuration for the compute environment.
- [`CfnComputeEnvironment.EksConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.EksConfigurationProperty.html) Struct Configuration for the Amazon EKS cluster that supports the AWS Batch compute environment.
- [`CfnComputeEnvironment.InfrastructureOptimizationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.InfrastructureOptimizationProperty.html) Struct
- [`CfnComputeEnvironment.InstanceLaunchTemplateProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.InstanceLaunchTemplateProperty.html) Struct
- [`CfnComputeEnvironment.InstanceRequirementsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.InstanceRequirementsProperty.html) Struct
- [`CfnComputeEnvironment.LaunchTemplateSpecificationOverrideProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.LaunchTemplateSpecificationOverrideProperty.html) Struct An object that represents a launch template to use in place of the default launch template.
- [`CfnComputeEnvironment.LaunchTemplateSpecificationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.LaunchTemplateSpecificationProperty.html) Struct An object that represents a launch template that's associated with a compute resource.
- [`CfnComputeEnvironment.ManagedInstancesLocalStorageConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.ManagedInstancesLocalStorageConfigurationProperty.html) Struct
- [`CfnComputeEnvironment.ManagedInstancesNetworkConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.ManagedInstancesNetworkConfigurationProperty.html) Struct
- [`CfnComputeEnvironment.ManagedInstancesProviderProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.ManagedInstancesProviderProperty.html) Struct
- [`CfnComputeEnvironment.ManagedInstancesStorageConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.ManagedInstancesStorageConfigurationProperty.html) Struct
- [`CfnComputeEnvironment.UpdatePolicyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironment.UpdatePolicyProperty.html) Struct Specifies the infrastructure update policy for the Amazon EC2 compute environment.
- [`CfnComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnComputeEnvironmentProps.html) Struct Properties for defining a `CfnComputeEnvironment`.
- [`CfnConsumableResourceProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnConsumableResourceProps.html) Struct Properties for defining a `CfnConsumableResource`.
- [`CfnJobDefinition.AuthorizationConfigProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.AuthorizationConfigProperty.html) Struct
- [`CfnJobDefinition.ConsumableResourcePropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.ConsumableResourcePropertiesProperty.html) Struct Contains a list of consumable resources required by a job.
- [`CfnJobDefinition.ConsumableResourceRequirementProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.ConsumableResourceRequirementProperty.html) Struct Information about a consumable resource required to run a job.
- [`CfnJobDefinition.ContainerPropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.ContainerPropertiesProperty.html) Struct Container properties are used for Amazon ECS based job definitions.
- [`CfnJobDefinition.DeviceProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.DeviceProperty.html) Struct An object that represents a container instance host device.
- [`CfnJobDefinition.EcsPropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EcsPropertiesProperty.html) Struct An object that contains the properties for the Amazon ECS resources of a job.
- [`CfnJobDefinition.EcsTaskPropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EcsTaskPropertiesProperty.html) Struct The properties for a task definition that describes the container and volume definitions of an Amazon ECS task.
- [`CfnJobDefinition.EfsVolumeConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EfsVolumeConfigurationProperty.html) Struct
- [`CfnJobDefinition.EksContainerEnvironmentVariableProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksContainerEnvironmentVariableProperty.html) Struct An environment variable.
- [`CfnJobDefinition.EksContainerLinuxCapabilitiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksContainerLinuxCapabilitiesProperty.html) Struct
- [`CfnJobDefinition.EksContainerProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksContainerProperty.html) Struct EKS container properties are used in job definitions for Amazon EKS based job definitions to describe the properties for a container node in the pod that's launched as part of a job.
- [`CfnJobDefinition.EksContainerVolumeMountProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksContainerVolumeMountProperty.html) Struct The volume mounts for a container for an Amazon EKS job.
- [`CfnJobDefinition.EksPersistentVolumeClaimProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksPersistentVolumeClaimProperty.html) Struct A `persistentVolumeClaim` volume is used to mount a [PersistentVolume](https://docs.aws.amazon.com/https://kubernetes.io/docs/concepts/storage/persistent-volumes/) into a Pod. PersistentVolumeClaims are a way for users to "claim" durable storage without knowing the details of the particular cloud environment. See the information about [PersistentVolumes](https://docs.aws.amazon.com/https://kubernetes.io/docs/concepts/storage/persistent-volumes/) in the *Kubernetes documentation* .
- [`CfnJobDefinition.EksPodSecurityContextProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksPodSecurityContextProperty.html) Struct
- [`CfnJobDefinition.EksPropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksPropertiesProperty.html) Struct An object that contains the properties for the Kubernetes resources of a job.
- [`CfnJobDefinition.EksSeccompProfileProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksSeccompProfileProperty.html) Struct
- [`CfnJobDefinition.EksSecretProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksSecretProperty.html) Struct Specifies the configuration of a Kubernetes `secret` volume.
- [`CfnJobDefinition.EksVolumeProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EksVolumeProperty.html) Struct Specifies an Amazon EKS volume for a job definition.
- [`CfnJobDefinition.EmptyDirProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EmptyDirProperty.html) Struct
- [`CfnJobDefinition.EnvironmentProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EnvironmentProperty.html) Struct The Environment property type specifies environment variables to use in a job definition.
- [`CfnJobDefinition.EphemeralStorageProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EphemeralStorageProperty.html) Struct The amount of ephemeral storage to allocate for the task.
- [`CfnJobDefinition.EvaluateOnExitProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EvaluateOnExitProperty.html) Struct Specifies an array of up to 5 conditions to be met, and an action to take ( `RETRY` or `EXIT` ) if all conditions are met.
- [`CfnJobDefinition.FargatePlatformConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.FargatePlatformConfigurationProperty.html) Struct The platform configuration for jobs that are running on Fargate resources.
- [`CfnJobDefinition.FirelensConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.FirelensConfigurationProperty.html) Struct The FireLens configuration for the container.
- [`CfnJobDefinition.HostPathProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.HostPathProperty.html) Struct
- [`CfnJobDefinition.ImagePullSecretProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.ImagePullSecretProperty.html) Struct References a Kubernetes secret resource.
- [`CfnJobDefinition.JobTimeoutProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.JobTimeoutProperty.html) Struct An object that represents a job timeout configuration.
- [`CfnJobDefinition.LinuxParametersProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.LinuxParametersProperty.html) Struct Linux-specific modifications that are applied to the container, such as details for device mappings.
- [`CfnJobDefinition.LogConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.LogConfigurationProperty.html) Struct Log configuration options to send to a custom log driver for the container.
- [`CfnJobDefinition.MetadataProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.MetadataProperty.html) Struct
- [`CfnJobDefinition.MountPointProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.MountPointProperty.html) Struct Details for a Docker volume mount point that's used in a job's container properties.
- [`CfnJobDefinition.MountPointsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.MountPointsProperty.html) Struct
- [`CfnJobDefinition.MultiNodeEcsPropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.MultiNodeEcsPropertiesProperty.html) Struct An object that contains the properties for the Amazon ECS resources of a job.
- [`CfnJobDefinition.MultiNodeEcsTaskPropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.MultiNodeEcsTaskPropertiesProperty.html) Struct The properties for a task definition that describes the container and volume definitions of an Amazon ECS task.
- [`CfnJobDefinition.NetworkConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.NetworkConfigurationProperty.html) Struct The network configuration for jobs that are running on Fargate resources.
- [`CfnJobDefinition.NodePropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.NodePropertiesProperty.html) Struct An object that represents the node properties of a multi-node parallel job.
- [`CfnJobDefinition.NodeRangePropertyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.NodeRangePropertyProperty.html) Struct This is an object that represents the properties of the node range for a multi-node parallel job.
- [`CfnJobDefinition.PodPropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.PodPropertiesProperty.html) Struct
- [`CfnJobDefinition.RepositoryCredentialsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.RepositoryCredentialsProperty.html) Struct The repository credentials for private registry authentication.
- [`CfnJobDefinition.ResourceRequirementProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.ResourceRequirementProperty.html) Struct The type and amount of a resource to assign to a container.
- [`CfnJobDefinition.ResourceRetentionPolicyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.ResourceRetentionPolicyProperty.html) Struct Specifies the resource retention policy settings for a job definition.
- [`CfnJobDefinition.ResourcesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.ResourcesProperty.html) Struct
- [`CfnJobDefinition.RetryStrategyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.RetryStrategyProperty.html) Struct The retry strategy that's associated with a job.
- [`CfnJobDefinition.RuntimePlatformProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.RuntimePlatformProperty.html) Struct An object that represents the compute environment architecture for AWS Batch jobs on Fargate.
- [`CfnJobDefinition.S3FilesVolumeConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.S3FilesVolumeConfigurationProperty.html) Struct
- [`CfnJobDefinition.SecretProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.SecretProperty.html) Struct An object that represents the secret to expose to your container.
- [`CfnJobDefinition.SecurityContextProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.SecurityContextProperty.html) Struct
- [`CfnJobDefinition.TaskContainerDependencyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.TaskContainerDependencyProperty.html) Struct A list of containers that this task depends on.
- [`CfnJobDefinition.TaskContainerPropertiesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.TaskContainerPropertiesProperty.html) Struct Container properties are used for Amazon ECS-based job definitions.
- [`CfnJobDefinition.TimeoutProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.TimeoutProperty.html) Struct
- [`CfnJobDefinition.TmpfsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.TmpfsProperty.html) Struct The container path, mount options, and size of the `tmpfs` mount.
- [`CfnJobDefinition.UlimitProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.UlimitProperty.html) Struct The `ulimit` settings to pass to the container. For more information, see [Ulimit](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Ulimit.html) .
- [`CfnJobDefinition.VolumesHostProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.VolumesHostProperty.html) Struct
- [`CfnJobDefinition.VolumesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.VolumesProperty.html) Struct
- [`CfnJobDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinitionProps.html) Struct Properties for defining a `CfnJobDefinition`.
- [`CfnJobQueue.ComputeEnvironmentOrderProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobQueue.ComputeEnvironmentOrderProperty.html) Struct The order that compute environments are tried in for job placement within a queue.
- [`CfnJobQueue.JobStateTimeLimitActionProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobQueue.JobStateTimeLimitActionProperty.html) Struct Specifies an action that AWS Batch will take after the job has remained at the head of the queue in the specified state for longer than the specified time.
- [`CfnJobQueue.ServiceEnvironmentOrderProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobQueue.ServiceEnvironmentOrderProperty.html) Struct Specifies the order of a service environment for a job queue.
- [`CfnJobQueueProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobQueueProps.html) Struct Properties for defining a `CfnJobQueue`.
- [`CfnQuotaShare.QuotaShareCapacityLimitProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnQuotaShare.QuotaShareCapacityLimitProperty.html) Struct
- [`CfnQuotaShare.QuotaSharePreemptionConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnQuotaShare.QuotaSharePreemptionConfigurationProperty.html) Struct
- [`CfnQuotaShare.QuotaShareResourceSharingConfigurationProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnQuotaShare.QuotaShareResourceSharingConfigurationProperty.html) Struct
- [`CfnQuotaShareProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnQuotaShareProps.html) Struct Properties for defining a `CfnQuotaShare`.
- [`CfnSchedulingPolicy.FairsharePolicyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnSchedulingPolicy.FairsharePolicyProperty.html) Struct The fair-share scheduling policy details.
- [`CfnSchedulingPolicy.QuotaSharePolicyProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnSchedulingPolicy.QuotaSharePolicyProperty.html) Struct Quota Share Policy for the Job Queue.
- [`CfnSchedulingPolicy.ShareAttributesProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnSchedulingPolicy.ShareAttributesProperty.html) Struct Specifies the weights for the share identifiers for the fair-share policy.
- [`CfnSchedulingPolicyProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnSchedulingPolicyProps.html) Struct Properties for defining a `CfnSchedulingPolicy`.
- [`CfnServiceEnvironment.CapacityLimitProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnServiceEnvironment.CapacityLimitProperty.html) Struct Defines the capacity limit for a service environment.
- [`CfnServiceEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnServiceEnvironmentProps.html) Struct Properties for defining a `CfnServiceEnvironment`.
- [`ComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ComputeEnvironmentProps.html) Struct Props common to all ComputeEnvironments.
- [`ConsumableResourceProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ConsumableResourceProps.html) Struct Properties for defining a Batch Consumable Resource.
- [`CustomReason`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CustomReason.html) Struct The corresponding Action will only be taken if *all* of the conditions specified here are met.
- [`Device`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Device.html) Struct A container instance host device.
- [`EcsContainerDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsContainerDefinitionProps.html) Struct Props to configure an EcsContainerDefinition.
- [`EcsEc2ContainerDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsEc2ContainerDefinitionProps.html) Struct Props to configure an EcsEc2ContainerDefinition.
- [`EcsFargateContainerDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsFargateContainerDefinitionProps.html) Struct Props to configure an EcsFargateContainerDefinition.
- [`EcsJobDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsJobDefinitionProps.html) Struct Props for EcsJobDefinition.
- [`EcsMachineImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsMachineImage.html) Struct A Batch MachineImage that is compatible with ECS.
- [`EcsVolumeOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsVolumeOptions.html) Struct Options to configure an EcsVolume.
- [`EfsVolumeOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EfsVolumeOptions.html) Struct Options for configuring an EfsVolume.
- [`EksContainerDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EksContainerDefinitionProps.html) Struct Props to configure an EksContainerDefinition.
- [`EksJobDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EksJobDefinitionProps.html) Struct Props for EksJobDefinition.
- [`EksMachineImage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EksMachineImage.html) Struct A Batch MachineImage that is compatible with EKS.
- [`EksVolumeOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EksVolumeOptions.html) Struct Options to configure an EksVolume.
- [`EmptyDirVolumeOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EmptyDirVolumeOptions.html) Struct Options for a Kubernetes EmptyDir volume.
- [`FairshareSchedulingPolicyProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.FairshareSchedulingPolicyProps.html) Struct Fairshare SchedulingPolicy configuration.
- [`FargateComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.FargateComputeEnvironmentProps.html) Struct Props for a FargateComputeEnvironment.
- [`HostPathVolumeOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.HostPathVolumeOptions.html) Struct Options for a kubernetes HostPath volume.
- [`HostVolumeOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.HostVolumeOptions.html) Struct Options for configuring an ECS HostVolume.
- [`JobDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobDefinitionProps.html) Struct Props common to all JobDefinitions.
- [`JobQueueProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobQueueProps.html) Struct Props to configure a JobQueue.
- [`JobStateTimeLimitAction`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobStateTimeLimitAction.html) Struct Specifies an action that AWS Batch will take after the job has remained at the head of the queue in the specified state for longer than the specified time.
- [`LinuxParametersProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.LinuxParametersProps.html) Struct The properties for defining Linux-specific options that are applied to the container.
- [`ManagedComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ManagedComputeEnvironmentProps.html) Struct Props for a ManagedComputeEnvironment.
- [`ManagedEc2ComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ManagedEc2ComputeEnvironmentProps.html) Struct Props for a ManagedEc2ComputeEnvironment.
- [`ManagedEc2EcsComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ManagedEc2EcsComputeEnvironmentProps.html) Struct Props for a ManagedEc2EcsComputeEnvironment.
- [`ManagedEc2EksComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ManagedEc2EksComputeEnvironmentProps.html) Struct Props for a ManagedEc2EksComputeEnvironment.
- [`MultiNodeContainer`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.MultiNodeContainer.html) Struct Runs the container on nodes [startNode, endNode].
- [`MultiNodeJobDefinitionProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.MultiNodeJobDefinitionProps.html) Struct Props to configure a MultiNodeJobDefinition.
- [`OrderedComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.OrderedComputeEnvironment.html) Struct Assigns an order to a ComputeEnvironment.
- [`SecretPathVolumeOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.SecretPathVolumeOptions.html) Struct Options for a Kubernetes SecretPath Volume.
- [`SecretVersionInfo`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.SecretVersionInfo.html) Struct Specify the secret's version id or version stage.
- [`Share`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Share.html) Struct Represents a group of Job Definitions.
- [`Tmpfs`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Tmpfs.html) Struct The details of a tmpfs mount for a container.
- [`Ulimit`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Ulimit.html) Struct Sets limits for a resource with `ulimit` on linux systems.
- [`UnmanagedComputeEnvironmentProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.UnmanagedComputeEnvironmentProps.html) Struct Represents an UnmanagedComputeEnvironment.

### Facades

- [`ConsumableResourceGrants`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ConsumableResourceGrants.html) Facade Collection of grant methods for a IConsumableResourceRef.

### Constructs

- [`EcsEc2ContainerDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsEc2ContainerDefinition.html) Construct A container orchestrated by ECS that uses EC2 resources.
- [`EcsFargateContainerDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsFargateContainerDefinition.html) Construct A container orchestrated by ECS that uses Fargate resources.
- [`EksContainerDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EksContainerDefinition.html) Construct A container that can be run with EKS orchestration on EC2 resources.
- [`LinuxParameters`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.LinuxParameters.html) Construct Linux-specific options that are applied to the container.

### Classes

- [`EcsVolume`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsVolume.html) Class Represents a Volume that can be mounted to a container that uses ECS.
- [`EfsVolume`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EfsVolume.html) Class A Volume that uses an AWS Elastic File System (EFS);
- [`EksVolume`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EksVolume.html) Class A Volume that can be mounted to a container supported by EKS.
- [`EmptyDirVolume`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EmptyDirVolume.html) Class A Kubernetes EmptyDir volume.
- [`HostPathVolume`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.HostPathVolume.html) Class A Kubernetes HostPath volume.
- [`HostVolume`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.HostVolume.html) Class Creates a Host volume.
- [`OptimalInstanceType`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.OptimalInstanceType.html) Class Not a real instance type!
- [`Reason`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Reason.html) Class Common job exit reasons.
- [`RetryStrategy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.RetryStrategy.html) Class Define how Jobs using this JobDefinition respond to different exit conditions.
- [`Secret`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Secret.html) Class A secret environment variable.
- [`SecretPathVolume`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.SecretPathVolume.html) Class Specifies the configuration of a Kubernetes secret volume.

### Interfaces

- [`IComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IComputeEnvironment.html) Interface Represents a ComputeEnvironment.
- [`IConsumableResource`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IConsumableResource.html) Interface Represents a Batch Consumable Resource.
- [`IEcsContainerDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IEcsContainerDefinition.html) Interface A container that can be run with ECS orchestration.
- [`IEcsEc2ContainerDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IEcsEc2ContainerDefinition.html) Interface A container orchestrated by ECS that uses EC2 resources.
- [`IEcsFargateContainerDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IEcsFargateContainerDefinition.html) Interface A container orchestrated by ECS that uses Fargate resources and is orchestrated by ECS.
- [`IEksContainerDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IEksContainerDefinition.html) Interface A container that can be run with EKS orchestration on EC2 resources.
- [`IEksJobDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IEksJobDefinition.html) Interface A JobDefinition that uses Eks orchestration.
- [`IFairshareSchedulingPolicy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IFairshareSchedulingPolicy.html) Interface Represents a Fairshare Scheduling Policy. Instructs the scheduler to allocate ComputeEnvironment vCPUs based on Job shareIdentifiers.
- [`IFargateComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IFargateComputeEnvironment.html) Interface A ManagedComputeEnvironment that uses ECS orchestration on Fargate instances.
- [`IJobDefinition`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IJobDefinition.html) Interface Represents a JobDefinition.
- [`IJobQueue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IJobQueue.html) Interface Represents a JobQueue.
- [`IManagedComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IManagedComputeEnvironment.html) Interface Represents a Managed ComputeEnvironment.
- [`IManagedEc2EcsComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IManagedEc2EcsComputeEnvironment.html) Interface A ManagedComputeEnvironment that uses ECS orchestration on EC2 instances.
- [`ISchedulingPolicy`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.ISchedulingPolicy.html) Interface Represents a Scheduling Policy.
- [`IUnmanagedComputeEnvironment`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.IUnmanagedComputeEnvironment.html) Interface Represents an UnmanagedComputeEnvironment.
