create_job_queue

create_job_queue(**kwargs)

Creates an Batch job queue. When you create a job queue, you associate one or more compute environments to the queue and assign an order of preference for the compute environments.

You also set a priority to the job queue that determines the order that the Batch scheduler places jobs onto its associated compute environments. For example, if a compute environment is associated with more than one job queue, the job queue with a higher priority is given preference for scheduling jobs to that compute environment.

See also: AWS API Documentation

Request Syntax

response = client.create_job_queue(
    jobQueueName='string',
    state='ENABLED'|'DISABLED',
    schedulingPolicyArn='string',
    priority=123,
    computeEnvironmentOrder=[
        {
            'order': 123,
            'computeEnvironment': 'string'
        },
    ],
    tags={
        'string': 'string'
    }
)
Parameters
  • jobQueueName (string) --

    [REQUIRED]

    The name of the job queue. It can be up to 128 letters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

  • state (string) -- The state of the job queue. If the job queue state is ENABLED , it is able to accept jobs. If the job queue state is DISABLED , new jobs can't be added to the queue, but jobs already in the queue can finish.
  • schedulingPolicyArn (string) -- The Amazon Resource Name (ARN) of the fair share scheduling policy. If this parameter is specified, the job queue uses a fair share scheduling policy. If this parameter isn't specified, the job queue uses a first in, first out (FIFO) scheduling policy. After a job queue is created, you can replace but can't remove the fair share scheduling policy. The format is aws:Partition:batch:Region:Account:scheduling-policy/Name . An example is aws:aws:batch:us-west-2:123456789012:scheduling-policy/MySchedulingPolicy .
  • priority (integer) --

    [REQUIRED]

    The priority of the job queue. Job queues with a higher priority (or a higher integer value for the priority parameter) are evaluated first when associated with the same compute environment. Priority is determined in descending order. For example, a job queue with a priority value of 10 is given scheduling preference over a job queue with a priority value of 1 . All of the compute environments must be either EC2 ( EC2 or SPOT ) or Fargate ( FARGATE or FARGATE_SPOT ); EC2 and Fargate compute environments can't be mixed.

  • computeEnvironmentOrder (list) --

    [REQUIRED]

    The set of compute environments mapped to a job queue and their order relative to each other. The job scheduler uses this parameter to determine which compute environment runs a specific job. Compute environments must be in the VALID state before you can associate them with a job queue. You can associate up to three compute environments with a job queue. All of the compute environments must be either EC2 ( EC2 or SPOT ) or Fargate ( FARGATE or FARGATE_SPOT ); EC2 and Fargate compute environments can't be mixed.

    Note

    All compute environments that are associated with a job queue must share the same architecture. Batch doesn't support mixing compute environment architecture types in a single job queue.

    • (dict) --

      The order that compute environments are tried in for job placement within a queue. Compute environments are tried in ascending order. For example, if two compute environments are associated with a job queue, the compute environment with a lower order integer value is tried for job placement first. Compute environments must be in the VALID state before you can associate them with a job queue. All of the compute environments must be either EC2 ( EC2 or SPOT ) or Fargate ( FARGATE or FARGATE_SPOT ); EC2 and Fargate compute environments can't be mixed.

      Note

      All compute environments that are associated with a job queue must share the same architecture. Batch doesn't support mixing compute environment architecture types in a single job queue.

      • order (integer) -- [REQUIRED]

        The order of the compute environment. Compute environments are tried in ascending order. For example, if two compute environments are associated with a job queue, the compute environment with a lower order integer value is tried for job placement first.

      • computeEnvironment (string) -- [REQUIRED]

        The Amazon Resource Name (ARN) of the compute environment.

  • tags (dict) --

    The tags that you apply to the job queue to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see Tagging your Batch resources in Batch User Guide .

    • (string) --
      • (string) --
Return type

dict

Returns

Response Syntax

{
    'jobQueueName': 'string',
    'jobQueueArn': 'string'
}

Response Structure

  • (dict) --

    • jobQueueName (string) --

      The name of the job queue.

    • jobQueueArn (string) --

      The Amazon Resource Name (ARN) of the job queue.

Exceptions

  • Batch.Client.exceptions.ClientException
  • Batch.Client.exceptions.ServerException

Examples

This example creates a job queue called LowPriority that uses the M4Spot compute environment.

response = client.create_job_queue(
    computeEnvironmentOrder=[
        {
            'computeEnvironment': 'M4Spot',
            'order': 1,
        },
    ],
    jobQueueName='LowPriority',
    priority=1,
    state='ENABLED',
)

print(response)

Expected Output:

{
    'jobQueueArn': 'arn:aws:batch:us-east-1:012345678910:job-queue/LowPriority',
    'jobQueueName': 'LowPriority',
    'ResponseMetadata': {
        '...': '...',
    },
}

This example creates a job queue called HighPriority that uses the C4OnDemand compute environment with an order of 1 and the M4Spot compute environment with an order of 2.

response = client.create_job_queue(
    computeEnvironmentOrder=[
        {
            'computeEnvironment': 'C4OnDemand',
            'order': 1,
        },
        {
            'computeEnvironment': 'M4Spot',
            'order': 2,
        },
    ],
    jobQueueName='HighPriority',
    priority=10,
    state='ENABLED',
)

print(response)

Expected Output:

{
    'jobQueueArn': 'arn:aws:batch:us-east-1:012345678910:job-queue/HighPriority',
    'jobQueueName': 'HighPriority',
    'ResponseMetadata': {
        '...': '...',
    },
}