# EcsMachineImage

A Batch MachineImage that is compatible with ECS.

- Source: [`aws-batch/lib/managed-compute-environment.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts#L385)
- Type last changed: v2.249.0 · 13 Apr 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_batch as batch } from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';

declare const machineImage: ec2.IMachineImage;
const ecsMachineImage: batch.EcsMachineImage = {
  image: machineImage,
  imageType: batch.EcsMachineImageType.ECS_AL2,
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_batch as batch
from aws_cdk import aws_ec2 as ec2

# machine_image: ec2.IMachineImage

ecs_machine_image = batch.EcsMachineImage(
    image=machine_image,
    image_type=batch.EcsMachineImageType.ECS_AL2
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.batch.*;
import software.amazon.awscdk.services.ec2.*;

IMachineImage machineImage;

EcsMachineImage ecsMachineImage = EcsMachineImage.builder()
        .image(machineImage)
        .imageType(EcsMachineImageType.ECS_AL2)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Batch;
using Amazon.CDK.AWS.EC2;

IMachineImage machineImage;

var ecsMachineImage = new EcsMachineImage {
    Image = machineImage,
    ImageType = EcsMachineImageType.ECS_AL2
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var machineImage IMachineImage

ecsMachineImage := &EcsMachineImage{
	Image: machineImage,
	ImageType: awscdk.Aws_batch.EcsMachineImageType_ECS_AL2,
}
```

## Properties

- `image`: [IMachineImage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IMachineImage.html) — The machine image to use.

  **Default:** chosen by batch

- `imageType`: [EcsMachineImageType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsMachineImageType.html) — Tells Batch which instance type to launch this image on.

  **Default:** 'ECS_AL2' for non-gpu instances, 'ECS_AL2_NVIDIA' for gpu instances. If the '@aws-cdk/aws-batch:defaultToAL2023' feature flag is set, 'ECS_AL2023' will be used instead of 'ECS_AL2'.
