# MultiNodeJobDefinitionProps

Props to configure a MultiNodeJobDefinition.

Extends: [JobDefinitionProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.JobDefinitionProps.html)
Used as props by: [MultiNodeJobDefinition](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.MultiNodeJobDefinition.html)

- Source: [`aws-batch/lib/multinode-job-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-batch/lib/multinode-job-definition.ts#L90)
- Type last changed: v2.99.0 · 28 Sep 2023

## Example

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
// Install: dotnet add package Amazon.CDK.Lib
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
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
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)),
	}),
})
```

## Properties

- `containers`: [MultiNodeContainer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.MultiNodeContainer.html)[] = none — The containers that this multinode job will run.

- `instanceType`: [InstanceType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.InstanceType.html) — The instance type that this job definition will run.

  **Default:** optimal instance, selected by Batch

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

  **Default:** generated by CloudFormation

- `mainNode`: number = 0 — The index of the main node in this job.

  The main node is responsible for orchestration.

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

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

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

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

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

  **Default:** no `RetryStrategy`

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

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

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

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

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

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

  **Default:** no timeout

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