LinuxCommandLibrary

aws-batch

Run batch computing workloads on AWS

TLDR

List running batch jobs

$ aws batch list-jobs --job-queue [queue_name]
copy

Create compute environment
$ aws batch create-compute-environment --compute-environment-name [compute_environment_name] --type [type]
copy

Create batch job queue
$ aws batch create-job-queue --job-queue-name [queue_name] --priority [priority] --compute-environment-order [compute_environment]
copy

Submit job
$ aws batch submit-job --job-name [job_name] --job-queue [job_queue] --job-definition [job_definition]
copy

Describe the list of batch jobs
$ aws batch describe-jobs --jobs [jobs]
copy

Cancel job
$ aws batch cancel-job --job-id [job_id] --reason [reason]
copy

SYNOPSIS

The `aws batch` functionality is accessed via the `aws` command.

General syntax for AWS CLI `batch` subcommands:
`aws batch <subcommand> [options] [arguments]`

Common `batch` subcommands include:
`aws batch describe-job-queues --query 'jobQueues[*].jobQueueName'`
`aws batch submit-job --job-name my-job --job-queue my-queue --job-definition my-job-def`
`aws batch terminate-job --job-id job-id-string --reason "reason-for-termination"`

PARAMETERS

General AWS CLI Global Options (apply to most `aws batch` commands)
    These options specify overall CLI behavior or target specific AWS configurations.

`--region <region-name>`
    Specifies the AWS region (e.g., `us-east-1`) to which the command applies.

`--output <format>`
    Defines the output format (e.g., `json`, `text`, `table`).

`--profile <profile-name>`
    Uses a specific named profile from your AWS credentials file.

Examples of `aws batch` Subcommand-Specific Parameters
    Parameters are unique to each `aws batch` subcommand. Below are common examples. Use `aws batch help` for full details.

`--job-name <string>`
    (Used with `submit-job`) The name of the job to be submitted.

`--job-queue <string>`
    (Used with `submit-job`) The ARN or name of the job queue where the job will be submitted.

`--job-definition <string>`
    (Used with `submit-job`) The ARN or name of the job definition that describes the job's configuration.

`--compute-environment-name <string>`
    (Used with `create-compute-environment`) A unique name for the new compute environment.

`--state <string>`
    (Used with `describe-job-queues`) Filters returned job queues based on their state (e.g., `VALID`, `INVALID`).

DESCRIPTION

aws-batch is not a standalone Linux command. Instead, it refers to the `batch` subcommand within the `aws` Command Line Interface (CLI), which provides a unified tool to manage your Amazon Web Services (AWS) resources and services directly from your terminal.

AWS Batch is a fully managed service that enables developers, scientists, and engineers to easily and efficiently run hundreds of thousands of batch computing jobs on AWS. It dynamically provisions the optimal quantity and type of compute resources (e.g., EC2 instances, Spot Instances, Fargate) based on the volume and specific resource requirements of the jobs you submit. It plans, schedules, and executes your batch computing workloads.

Through the `aws batch` CLI, users can define job queues, compute environments, job definitions, and then submit, monitor, and manage their batch jobs. This allows for automation of workflows, processing large datasets, performing high-throughput computations, and more, without needing to manage the underlying infrastructure.

CAVEATS

aws-batch refers to the `aws batch` CLI functionality, which is not a standalone executable. It requires the `AWS CLI` to be installed and configured with appropriate AWS credentials.

Using AWS Batch incurs costs based on the underlying AWS resources (EC2 instances, EBS volumes, Fargate, etc.) that it provisions.

Proper `IAM permissions` are crucial for interacting with AWS Batch resources. Users or roles need specific permissions (e.g., `batch:SubmitJob`, `batch:DescribeJobs`) to perform operations.

FINDING HELP FOR AWS CLI BATCH COMMANDS

To discover all available `aws batch` subcommands and their specific parameters, you can use the `help` option with the `aws` command:
`aws batch help` - Shows all `batch` subcommands.
`aws batch <subcommand> help` - Shows options and arguments for a specific subcommand, e.g., `aws batch submit-job help`.
This provides detailed documentation directly in your terminal.

HISTORY

AWS Batch was first announced by Amazon Web Services in `February 2017`, aiming to provide a fully managed service for batch computing workloads. Before its introduction, users had to manually provision and manage compute clusters using services like EC2 and orchestrate jobs with custom scripts or open-source schedulers. AWS Batch streamlined this process by offering integrated job scheduling, resource provisioning, and scaling capabilities. Its development focused on abstracting infrastructure management, allowing users to concentrate on their application logic. Over time, it has integrated with other AWS services like Fargate for serverless container execution and expanded its capabilities for various workload types.

SEE ALSO

aws(1): The main AWS CLI command., aws ec2(1): For managing Elastic Compute Cloud instances, often the underlying compute for Batch., aws ecs(1): For managing Elastic Container Service, which AWS Batch uses for container orchestration., aws logs(1): For interacting with CloudWatch Logs, where Batch job logs are often sent.

Copied to clipboard