Skip to content

Batch

CloudMock emulates AWS Batch, supporting compute environments, job queues, job definitions, scheduling policies, job submission/management, and resource tagging. Job state transitions are simulated synchronously in test mode.

OperationStatusNotes
CreateComputeEnvironmentSupportedMANAGED and UNMANAGED types; state machine: CREATING → VALID
DescribeComputeEnvironmentsSupportedFilter by name or ARN
UpdateComputeEnvironmentSupportedUpdate state or service role
DeleteComputeEnvironmentSupportedStops lifecycle machine
CreateJobQueueSupportedPriority-ordered compute environment list
DescribeJobQueuesSupportedFilter by name or ARN
UpdateJobQueueSupportedUpdate state, priority, or CE order
DeleteJobQueueSupported
RegisterJobDefinitionSupportedMulti-revision support per definition name
DescribeJobDefinitionsSupportedFilter by name or status
DeregisterJobDefinitionSupportedMarks revision as INACTIVE
SubmitJobSupportedSupports dependsOn chains
DescribeJobsSupportedReturns full job detail
ListJobsSupportedFilter by queue and status
CancelJobSupportedOnly cancels non-terminal jobs
TerminateJobSupportedForce-stops running jobs
CreateSchedulingPolicySupportedFair-share scheduling policies
DescribeSchedulingPoliciesSupportedFilter by ARN
UpdateSchedulingPolicySupportedUpdate fair-share parameters
DeleteSchedulingPolicySupported
TagResourceSupportedTag any Batch resource by ARN
UntagResourceSupported
ListTagsForResourceSupported
SUBMITTED → PENDING → RUNNABLE → STARTING → RUNNING → SUCCEEDED / FAILED

Transitions are simulated with configurable delays. In test mode (instant lifecycle), all transitions happen synchronously.

import { BatchClient, CreateComputeEnvironmentCommand, CreateJobQueueCommand, RegisterJobDefinitionCommand, SubmitJobCommand } from '@aws-sdk/client-batch';
const client = new BatchClient({
endpoint: 'http://localhost:4566',
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
await client.send(new CreateComputeEnvironmentCommand({
computeEnvironmentName: 'my-ce',
type: 'MANAGED',
state: 'ENABLED',
computeResources: { type: 'EC2', maxvCpus: 256, instanceTypes: ['m5.xlarge'] },
}));
await client.send(new CreateJobQueueCommand({
jobQueueName: 'my-queue',
state: 'ENABLED',
priority: 10,
computeEnvironmentOrder: [{ computeEnvironment: 'my-ce', order: 1 }],
}));
await client.send(new RegisterJobDefinitionCommand({
jobDefinitionName: 'my-job-def',
type: 'container',
containerProperties: { image: 'alpine:latest', vcpus: 1, memory: 512 },
}));
const { jobId } = await client.send(new SubmitJobCommand({
jobName: 'my-job',
jobQueue: 'my-queue',
jobDefinition: 'my-job-def:1',
}));
console.log('Submitted job:', jobId);
import boto3
client = boto3.client('batch',
endpoint_url='http://localhost:4566',
region_name='us-east-1',
aws_access_key_id='test',
aws_secret_access_key='test')
client.create_compute_environment(
computeEnvironmentName='my-ce',
type='MANAGED',
state='ENABLED',
computeResources={'type': 'EC2', 'maxvCpus': 256, 'instanceTypes': ['m5.xlarge']})
response = client.submit_job(
jobName='my-job',
jobQueue='my-queue',
jobDefinition='my-job-def:1')
print(response['jobId'])
cloudmock.yml
services:
batch:
enabled: true
  • Jobs are not actually executed on compute resources
  • Job status transitions are simulated (not driven by real compute)
  • Compute environments do not provision real EC2 instances
  • Fair-share scheduling policies are stored but not enforced during job dispatch