Batch / Client / create_job_queue
create_job_queue#
- Batch.Client.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' }, jobStateTimeLimitActions=[ { 'reason': 'string', 'state': 'RUNNABLE', 'maxTimeSeconds': 123, 'action': 'CANCEL' }, ] )
- 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 isDISABLED
, 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 of10
is given scheduling preference over a job queue with a priority value of1
. All of the compute environments must be either EC2 (EC2
orSPOT
) or Fargate (FARGATE
orFARGATE_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
orSPOT
) or Fargate (FARGATE
orFARGATE_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
orSPOT
) or Fargate (FARGATE
orFARGATE_SPOT
); Amazon 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) –
jobStateTimeLimitActions (list) –
The set of actions that Batch performs on jobs that remain at the head of the job queue in the specified state longer than specified times. Batch will perform each action after
maxTimeSeconds
has passed.(dict) –
Specifies an action that Batch will take after the job has remained at the head of the queue in the specified state for longer than the specified time.
reason (string) – [REQUIRED]
The reason to log for the action being taken.
state (string) – [REQUIRED]
The state of the job needed to trigger the action. The only supported value is
RUNNABLE
.maxTimeSeconds (integer) – [REQUIRED]
The approximate amount of time, in seconds, that must pass with the job in the specified state before the action is taken. The minimum value is 600 (10 minutes) and the maximum value is 86,400 (24 hours).
action (string) – [REQUIRED]
The action to take when a job is at the head of the job queue in the specified state for the specified period of time. The only supported value is
CANCEL
, which will cancel the job.
- 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': { '...': '...', }, }