The AWS SDK for JavaScript v2 has reached end-of-support.
We recommend that you migrate to AWS SDK for JavaScript v3. For additional details and information on how to migrate, please refer to the announcement.

Class: AWS.Batch

Inherits:
AWS.Service show all
Identifier:
batch
API Version:
2016-08-10
Defined in:
(unknown)

Overview

Constructs a service interface object. Each API operation is exposed as a function on service.

Service Description

Using Batch, you can run batch computing workloads on the Amazon Web Services Cloud. Batch computing is a common means for developers, scientists, and engineers to access large amounts of compute resources. Batch uses the advantages of the batch computing to remove the undifferentiated heavy lifting of configuring and managing required infrastructure. At the same time, it also adopts a familiar batch computing software approach. You can use Batch to efficiently provision resources, and work toward eliminating capacity constraints, reducing your overall compute costs, and delivering results more quickly.

As a fully managed service, Batch can run batch computing workloads of any scale. Batch automatically provisions compute resources and optimizes workload distribution based on the quantity and scale of your specific workloads. With Batch, there's no need to install or manage batch computing software. This means that you can focus on analyzing results and solving your specific problems instead.

Sending a Request Using Batch

var batch = new AWS.Batch();
batch.cancelJob(params, function (err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Locking the API Version

In order to ensure that the Batch object uses this specific API, you can construct the object by passing the apiVersion option to the constructor:

var batch = new AWS.Batch({apiVersion: '2016-08-10'});

You can also set the API version globally in AWS.config.apiVersions using the batch service identifier:

AWS.config.apiVersions = {
  batch: '2016-08-10',
  // other service API versions
};

var batch = new AWS.Batch();

Version:

  • 2016-08-10

Constructor Summary collapse

Property Summary collapse

Properties inherited from AWS.Service

apiVersions

Method Summary collapse

Methods inherited from AWS.Service

makeRequest, makeUnauthenticatedRequest, waitFor, setupRequestListeners, defineService

Constructor Details

new AWS.Batch(options = {}) ⇒ Object

Constructs a service object. This object has one method for each API operation.

Examples:

Constructing a Batch object

var batch = new AWS.Batch({apiVersion: '2016-08-10'});

Options Hash (options):

  • params (map)

    An optional map of parameters to bind to every request sent by this service object. For more information on bound parameters, see "Working with Services" in the Getting Started Guide.

  • endpoint (String|AWS.Endpoint)

    The endpoint URI to send requests to. The default endpoint is built from the configured region. The endpoint should be a string like 'https://{service}.{region}.amazonaws.com' or an Endpoint object.

  • accessKeyId (String)

    your AWS access key ID.

  • secretAccessKey (String)

    your AWS secret access key.

  • sessionToken (AWS.Credentials)

    the optional AWS session token to sign requests with.

  • credentials (AWS.Credentials)

    the AWS credentials to sign requests with. You can either specify this object, or specify the accessKeyId and secretAccessKey options directly.

  • credentialProvider (AWS.CredentialProviderChain)

    the provider chain used to resolve credentials if no static credentials property is set.

  • region (String)

    the region to send service requests to. See AWS.Batch.region for more information.

  • maxRetries (Integer)

    the maximum amount of retries to attempt with a request. See AWS.Batch.maxRetries for more information.

  • maxRedirects (Integer)

    the maximum amount of redirects to follow with a request. See AWS.Batch.maxRedirects for more information.

  • sslEnabled (Boolean)

    whether to enable SSL for requests.

  • paramValidation (Boolean|map)

    whether input parameters should be validated against the operation description before sending the request. Defaults to true. Pass a map to enable any of the following specific validation features:

    • min [Boolean] — Validates that a value meets the min constraint. This is enabled by default when paramValidation is set to true.
    • max [Boolean] — Validates that a value meets the max constraint.
    • pattern [Boolean] — Validates that a string value matches a regular expression.
    • enum [Boolean] — Validates that a string value matches one of the allowable enum values.
  • computeChecksums (Boolean)

    whether to compute checksums for payload bodies when the service accepts it (currently supported in S3 only)

  • convertResponseTypes (Boolean)

    whether types are converted when parsing response data. Currently only supported for JSON based services. Turning this off may improve performance on large response payloads. Defaults to true.

  • correctClockSkew (Boolean)

    whether to apply a clock skew correction and retry requests that fail because of an skewed client clock. Defaults to false.

  • s3ForcePathStyle (Boolean)

    whether to force path style URLs for S3 objects.

  • s3BucketEndpoint (Boolean)

    whether the provided endpoint addresses an individual bucket (false if it addresses the root API endpoint). Note that setting this configuration option requires an endpoint to be provided explicitly to the service constructor.

  • s3DisableBodySigning (Boolean)

    whether S3 body signing should be disabled when using signature version v4. Body signing can only be disabled when using https. Defaults to true.

  • s3UsEast1RegionalEndpoint ('legacy'|'regional')

    when region is set to 'us-east-1', whether to send s3 request to global endpoints or 'us-east-1' regional endpoints. This config is only applicable to S3 client. Defaults to legacy

  • s3UseArnRegion (Boolean)

    whether to override the request region with the region inferred from requested resource's ARN. Only available for S3 buckets Defaults to true

  • retryDelayOptions (map)

    A set of options to configure the retry delay on retryable errors. Currently supported options are:

    • base [Integer] — The base number of milliseconds to use in the exponential backoff for operation retries. Defaults to 100 ms for all services except DynamoDB, where it defaults to 50ms.
    • customBackoff [function] — A custom function that accepts a retry count and error and returns the amount of time to delay in milliseconds. If the result is a non-zero negative value, no further retry attempts will be made. The base option will be ignored if this option is supplied. The function is only called for retryable errors.
  • httpOptions (map)

    A set of options to pass to the low-level HTTP request. Currently supported options are:

    • proxy [String] — the URL to proxy requests through
    • agent [http.Agent, https.Agent] — the Agent object to perform HTTP requests with. Used for connection pooling. Defaults to the global agent (http.globalAgent) for non-SSL connections. Note that for SSL connections, a special Agent object is used in order to enable peer certificate verification. This feature is only available in the Node.js environment.
    • connectTimeout [Integer] — Sets the socket to timeout after failing to establish a connection with the server after connectTimeout milliseconds. This timeout has no effect once a socket connection has been established.
    • timeout [Integer] — Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Defaults to two minutes (120000).
    • xhrAsync [Boolean] — Whether the SDK will send asynchronous HTTP requests. Used in the browser environment only. Set to false to send requests synchronously. Defaults to true (async on).
    • xhrWithCredentials [Boolean] — Sets the "withCredentials" property of an XMLHttpRequest object. Used in the browser environment only. Defaults to false.
  • apiVersion (String, Date)

    a String in YYYY-MM-DD format (or a date) that represents the latest possible API version that can be used in all services (unless overridden by apiVersions). Specify 'latest' to use the latest possible version.

  • apiVersions (map<String, String|Date>)

    a map of service identifiers (the lowercase service class name) with the API version to use when instantiating a service. Specify 'latest' for each individual that can use the latest available version.

  • logger (#write, #log)

    an object that responds to .write() (like a stream) or .log() (like the console object) in order to log information about requests

  • systemClockOffset (Number)

    an offset value in milliseconds to apply to all signing times. Use this to compensate for clock skew when your system may be out of sync with the service time. Note that this configuration option can only be applied to the global AWS.config object and cannot be overridden in service-specific configuration. Defaults to 0 milliseconds.

  • signatureVersion (String)

    the signature version to sign requests with (overriding the API configuration). Possible values are: 'v2', 'v3', 'v4'.

  • signatureCache (Boolean)

    whether the signature to sign requests with (overriding the API configuration) is cached. Only applies to the signature version 'v4'. Defaults to true.

  • dynamoDbCrc32 (Boolean)

    whether to validate the CRC32 checksum of HTTP response bodies returned by DynamoDB. Default: true.

  • useAccelerateEndpoint (Boolean)

    Whether to use the S3 Transfer Acceleration endpoint with the S3 service. Default: false.

  • clientSideMonitoring (Boolean)

    whether to collect and publish this client's performance metrics of all its API requests.

  • endpointDiscoveryEnabled (Boolean|undefined)

    whether to call operations with endpoints given by service dynamically. Setting this

  • endpointCacheSize (Number)

    the size of the global cache storing endpoints from endpoint discovery operations. Once endpoint cache is created, updating this setting cannot change existing cache size. Defaults to 1000

  • hostPrefixEnabled (Boolean)

    whether to marshal request parameters to the prefix of hostname. Defaults to true.

  • stsRegionalEndpoints ('legacy'|'regional')

    whether to send sts request to global endpoints or regional endpoints. Defaults to 'legacy'.

  • useFipsEndpoint (Boolean)

    Enables FIPS compatible endpoints. Defaults to false.

  • useDualstackEndpoint (Boolean)

    Enables IPv6 dualstack endpoint. Defaults to false.

Property Details

endpointAWS.Endpoint (readwrite)

Returns an Endpoint object representing the endpoint URL for service requests.

Returns:

  • (AWS.Endpoint)

    an Endpoint object representing the endpoint URL for service requests.

Method Details

cancelJob(params = {}, callback) ⇒ AWS.Request

Cancels a job in an Batch job queue. Jobs that are in a SUBMITTED, PENDING, or RUNNABLE state are cancelled and the job status is updated to FAILED.

Note: A PENDING job is canceled after all dependency jobs are completed. Therefore, it may take longer than expected to cancel a job in PENDING status. When you try to cancel an array parent job in PENDING, Batch attempts to cancel all child jobs. The array parent job is canceled when all child jobs are completed.

Jobs that progressed to the STARTING or RUNNING state aren't canceled. However, the API operation still succeeds, even if no job is canceled. These jobs must be terminated with the TerminateJob operation.

Service Reference:

Examples:

To cancel a job


/* This example cancels a job with the specified job ID. */

 var params = {
  jobId: "1d828f65-7a4d-42e8-996d-3b900ed59dc4", 
  reason: "Cancelling job."
 };
 batch.cancelJob(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
   }
   */
 });

Calling the cancelJob operation

var params = {
  jobId: 'STRING_VALUE', /* required */
  reason: 'STRING_VALUE' /* required */
};
batch.cancelJob(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • jobId — (String)

      The Batch job ID of the job to cancel.

    • reason — (String)

      A message to attach to the job that explains the reason for canceling it. This message is returned by future DescribeJobs operations on the job. This message is also recorded in the Batch activity logs.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

createComputeEnvironment(params = {}, callback) ⇒ AWS.Request

Creates an Batch compute environment. You can create MANAGED or UNMANAGED compute environments. MANAGED compute environments can use Amazon EC2 or Fargate resources. UNMANAGED compute environments can only use EC2 resources.

In a managed compute environment, Batch manages the capacity and instance types of the compute resources within the environment. This is based on the compute resource specification that you define or the launch template that you specify when you create the compute environment. Either, you can choose to use EC2 On-Demand Instances and EC2 Spot Instances. Or, you can use Fargate and Fargate Spot capacity in your managed compute environment. You can optionally set a maximum price so that Spot Instances only launch when the Spot Instance price is less than a specified percentage of the On-Demand price.

Note: Multi-node parallel jobs aren't supported on Spot Instances.

In an unmanaged compute environment, you can manage your own EC2 compute resources and have flexibility with how you configure your compute resources. For example, you can use custom AMIs. However, you must verify that each of your AMIs meet the Amazon ECS container instance AMI specification. For more information, see container instance AMIs in the Amazon Elastic Container Service Developer Guide. After you created your unmanaged compute environment, you can use the DescribeComputeEnvironments operation to find the Amazon ECS cluster that's associated with it. Then, launch your container instances into that Amazon ECS cluster. For more information, see Launching an Amazon ECS container instance in the Amazon Elastic Container Service Developer Guide.

Note: To create a compute environment that uses EKS resources, the caller must have permissions to call eks:DescribeCluster.
Note: Batch doesn't automatically upgrade the AMIs in a compute environment after it's created. For example, it also doesn't update the AMIs in your compute environment when a newer version of the Amazon ECS optimized AMI is available. You're responsible for the management of the guest operating system. This includes any updates and security patches. You're also responsible for any additional application software or utilities that you install on the compute resources. There are two ways to use a new AMI for your Batch jobs. The original method is to complete these steps:
  1. Create a new compute environment with the new AMI.
  2. Add the compute environment to an existing job queue.
  3. Remove the earlier compute environment from your job queue.
  4. Delete the earlier compute environment.
In April 2022, Batch added enhanced support for updating compute environments. For more information, see Updating compute environments. To use the enhanced updating of compute environments to update AMIs, follow these rules:
  • Either don't set the service role (serviceRole) parameter or set it to the AWSBatchServiceRole service-linked role.
  • Set the allocation strategy (allocationStrategy) parameter to BEST_FIT_PROGRESSIVE, SPOT_CAPACITY_OPTIMIZED, or SPOT_PRICE_CAPACITY_OPTIMIZED.
  • Set the update to latest image version (updateToLatestImageVersion) parameter to true. The updateToLatestImageVersion parameter is used when you update a compute environment. This parameter is ignored when you create a compute environment.
  • Don't specify an AMI ID in imageId, imageIdOverride (in ec2Configuration ), or in the launch template (launchTemplate). In that case, Batch selects the latest Amazon ECS optimized AMI that's supported by Batch at the time the infrastructure update is initiated. Alternatively, you can specify the AMI ID in the imageId or imageIdOverride parameters, or the launch template identified by the LaunchTemplate properties. Changing any of these properties starts an infrastructure update. If the AMI ID is specified in the launch template, it can't be replaced by specifying an AMI ID in either the imageId or imageIdOverride parameters. It can only be replaced by specifying a different launch template, or if the launch template version is set to $Default or $Latest, by setting either a new default version for the launch template (if $Default) or by adding a new version to the launch template (if $Latest).
If these rules are followed, any update that starts an infrastructure update causes the AMI ID to be re-selected. If the version setting in the launch template (launchTemplate) is set to $Latest or $Default, the latest or default version of the launch template is evaluated up at the time of the infrastructure update, even if the launchTemplate wasn't updated.

Service Reference:

Examples:

To create a managed EC2 compute environment


/* This example creates a managed compute environment with specific C4 instance types that are launched on demand. The compute environment is called C4OnDemand. */

 var params = {
  type: "MANAGED", 
  computeEnvironmentName: "C4OnDemand", 
  computeResources: {
   type: "EC2", 
   desiredvCpus: 48, 
   ec2KeyPair: "id_rsa", 
   instanceRole: "ecsInstanceRole", 
   instanceTypes: [
      "c4.large", 
      "c4.xlarge", 
      "c4.2xlarge", 
      "c4.4xlarge", 
      "c4.8xlarge"
   ], 
   maxvCpus: 128, 
   minvCpus: 0, 
   securityGroupIds: [
      "sg-cf5093b2"
   ], 
   subnets: [
      "subnet-220c0e0a", 
      "subnet-1a95556d", 
      "subnet-978f6dce"
   ], 
   tags: {
    "Name": "Batch Instance - C4OnDemand"
   }
  }, 
  serviceRole: "arn:aws:iam::012345678910:role/AWSBatchServiceRole", 
  state: "ENABLED"
 };
 batch.createComputeEnvironment(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    computeEnvironmentArn: "arn:aws:batch:us-east-1:012345678910:compute-environment/C4OnDemand", 
    computeEnvironmentName: "C4OnDemand"
   }
   */
 });

To create a managed EC2 Spot compute environment


/* This example creates a managed compute environment with the M4 instance type that is launched when the Spot bid price is at or below 20% of the On-Demand price for the instance type. The compute environment is called M4Spot. */

 var params = {
  type: "MANAGED", 
  computeEnvironmentName: "M4Spot", 
  computeResources: {
   type: "SPOT", 
   bidPercentage: 20, 
   desiredvCpus: 4, 
   ec2KeyPair: "id_rsa", 
   instanceRole: "ecsInstanceRole", 
   instanceTypes: [
      "m4"
   ], 
   maxvCpus: 128, 
   minvCpus: 0, 
   securityGroupIds: [
      "sg-cf5093b2"
   ], 
   spotIamFleetRole: "arn:aws:iam::012345678910:role/aws-ec2-spot-fleet-role", 
   subnets: [
      "subnet-220c0e0a", 
      "subnet-1a95556d", 
      "subnet-978f6dce"
   ], 
   tags: {
    "Name": "Batch Instance - M4Spot"
   }
  }, 
  serviceRole: "arn:aws:iam::012345678910:role/AWSBatchServiceRole", 
  state: "ENABLED"
 };
 batch.createComputeEnvironment(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    computeEnvironmentArn: "arn:aws:batch:us-east-1:012345678910:compute-environment/M4Spot", 
    computeEnvironmentName: "M4Spot"
   }
   */
 });

Calling the createComputeEnvironment operation

var params = {
  computeEnvironmentName: 'STRING_VALUE', /* required */
  type: MANAGED | UNMANAGED, /* required */
  computeResources: {
    maxvCpus: 'NUMBER_VALUE', /* required */
    subnets: [ /* required */
      'STRING_VALUE',
      /* more items */
    ],
    type: EC2 | SPOT | FARGATE | FARGATE_SPOT, /* required */
    allocationStrategy: BEST_FIT | BEST_FIT_PROGRESSIVE | SPOT_CAPACITY_OPTIMIZED | SPOT_PRICE_CAPACITY_OPTIMIZED,
    bidPercentage: 'NUMBER_VALUE',
    desiredvCpus: 'NUMBER_VALUE',
    ec2Configuration: [
      {
        imageType: 'STRING_VALUE', /* required */
        imageIdOverride: 'STRING_VALUE',
        imageKubernetesVersion: 'STRING_VALUE'
      },
      /* more items */
    ],
    ec2KeyPair: 'STRING_VALUE',
    imageId: 'STRING_VALUE',
    instanceRole: 'STRING_VALUE',
    instanceTypes: [
      'STRING_VALUE',
      /* more items */
    ],
    launchTemplate: {
      launchTemplateId: 'STRING_VALUE',
      launchTemplateName: 'STRING_VALUE',
      version: 'STRING_VALUE'
    },
    minvCpus: 'NUMBER_VALUE',
    placementGroup: 'STRING_VALUE',
    securityGroupIds: [
      'STRING_VALUE',
      /* more items */
    ],
    spotIamFleetRole: 'STRING_VALUE',
    tags: {
      '<String>': 'STRING_VALUE',
      /* '<String>': ... */
    }
  },
  context: 'STRING_VALUE',
  eksConfiguration: {
    eksClusterArn: 'STRING_VALUE', /* required */
    kubernetesNamespace: 'STRING_VALUE' /* required */
  },
  serviceRole: 'STRING_VALUE',
  state: ENABLED | DISABLED,
  tags: {
    '<TagKey>': 'STRING_VALUE',
    /* '<TagKey>': ... */
  },
  unmanagedvCpus: 'NUMBER_VALUE'
};
batch.createComputeEnvironment(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • computeEnvironmentName — (String)

      The name for your compute environment. It can be up to 128 characters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

    • type — (String)

      The type of the compute environment: MANAGED or UNMANAGED. For more information, see Compute Environments in the Batch User Guide.

      Possible values include:
      • "MANAGED"
      • "UNMANAGED"
    • state — (String)

      The state of the compute environment. If the state is ENABLED, then the compute environment accepts jobs from a queue and can scale out automatically based on queues.

      If the state is ENABLED, then the Batch scheduler can attempt to place jobs from an associated job queue on the compute resources within the environment. If the compute environment is managed, then it can scale its instances out or in automatically, based on the job queue demand.

      If the state is DISABLED, then the Batch scheduler doesn't attempt to place jobs within the environment. Jobs in a STARTING or RUNNING state continue to progress normally. Managed compute environments in the DISABLED state don't scale out.

      Note: Compute environments in a DISABLED state may continue to incur billing charges. To prevent additional charges, turn off and then delete the compute environment. For more information, see State in the Batch User Guide.

      When an instance is idle, the instance scales down to the minvCpus value. However, the instance size doesn't change. For example, consider a c5.8xlarge instance with a minvCpus value of 4 and a desiredvCpus value of 36. This instance doesn't scale down to a c5.large instance.

      Possible values include:
      • "ENABLED"
      • "DISABLED"
    • unmanagedvCpus — (Integer)

      The maximum number of vCPUs for an unmanaged compute environment. This parameter is only used for fair share scheduling to reserve vCPU capacity for new share identifiers. If this parameter isn't provided for a fair share job queue, no vCPU capacity is reserved.

      Note: This parameter is only supported when the type parameter is set to UNMANAGED.
    • computeResources — (map)

      Details about the compute resources managed by the compute environment. This parameter is required for managed compute environments. For more information, see Compute Environments in the Batch User Guide.

      • typerequired — (String)

        The type of compute environment: EC2, SPOT, FARGATE, or FARGATE_SPOT. For more information, see Compute environments in the Batch User Guide.

        If you choose SPOT, you must also specify an Amazon EC2 Spot Fleet role with the spotIamFleetRole parameter. For more information, see Amazon EC2 spot fleet role in the Batch User Guide.

        Possible values include:
        • "EC2"
        • "SPOT"
        • "FARGATE"
        • "FARGATE_SPOT"
      • allocationStrategy — (String)

        The allocation strategy to use for the compute resource if not enough instances of the best fitting instance type can be allocated. This might be because of availability of the instance type in the Region or Amazon EC2 service limits. For more information, see Allocation strategies in the Batch User Guide.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
        BEST_FIT (default)

        Batch selects an instance type that best fits the needs of the jobs with a preference for the lowest-cost instance type. If additional instances of the selected instance type aren't available, Batch waits for the additional instances to be available. If there aren't enough instances available or the user is reaching Amazon EC2 service limits, additional jobs aren't run until the currently running jobs are completed. This allocation strategy keeps costs lower but can limit scaling. If you're using Spot Fleets with BEST_FIT, the Spot Fleet IAM Role must be specified. Compute resources that use a BEST_FIT allocation strategy don't support infrastructure updates and can't update some parameters. For more information, see Updating compute environments in the Batch User Guide.

        BEST_FIT_PROGRESSIVE

        Batch selects additional instance types that are large enough to meet the requirements of the jobs in the queue. Its preference is for instance types with lower cost vCPUs. If additional instances of the previously selected instance types aren't available, Batch selects new instance types.

        SPOT_CAPACITY_OPTIMIZED

        Batch selects one or more instance types that are large enough to meet the requirements of the jobs in the queue. Its preference is for instance types that are less likely to be interrupted. This allocation strategy is only available for Spot Instance compute resources.

        SPOT_PRICE_CAPACITY_OPTIMIZED

        The price and capacity optimized allocation strategy looks at both price and capacity to select the Spot Instance pools that are the least likely to be interrupted and have the lowest possible price. This allocation strategy is only available for Spot Instance compute resources.

        With BEST_FIT_PROGRESSIVE,SPOT_CAPACITY_OPTIMIZED and SPOT_PRICE_CAPACITY_OPTIMIZED (recommended) strategies using On-Demand or Spot Instances, and the BEST_FIT strategy using Spot Instances, Batch might need to exceed maxvCpus to meet your capacity requirements. In this event, Batch never exceeds maxvCpus by more than a single instance.

        Possible values include:
        • "BEST_FIT"
        • "BEST_FIT_PROGRESSIVE"
        • "SPOT_CAPACITY_OPTIMIZED"
        • "SPOT_PRICE_CAPACITY_OPTIMIZED"
      • minvCpus — (Integer)

        The minimum number of vCPUs that a compute environment should maintain (even if the compute environment is DISABLED).

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
      • maxvCpusrequired — (Integer)

        The maximum number of vCPUs that a compute environment can support.

        Note: With BEST_FIT_PROGRESSIVE,SPOT_CAPACITY_OPTIMIZED and SPOT_PRICE_CAPACITY_OPTIMIZED (recommended) strategies using On-Demand or Spot Instances, and the BEST_FIT strategy using Spot Instances, Batch might need to exceed maxvCpus to meet your capacity requirements. In this event, Batch never exceeds maxvCpus by more than a single instance.
      • desiredvCpus — (Integer)

        The desired number of vCPUS in the compute environment. Batch modifies this value between the minimum and maximum values based on job queue demand.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
      • instanceTypes — (Array<String>)

        The instances types that can be launched. You can specify instance families to launch any instance type within those families (for example, c5 or p3), or you can specify specific sizes within a family (such as c5.8xlarge). You can also choose optimal to select instance types (from the C4, M4, and R4 instance families) that match the demand of your job queues.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
        Note: When you create a compute environment, the instance types that you select for the compute environment must share the same architecture. For example, you can't mix x86 and ARM instances in the same compute environment.
        Note: Currently, optimal uses instance types from the C4, M4, and R4 instance families. In Regions that don't have instance types from those instance families, instance types from the C5, M5, and R5 instance families are used.
      • imageId — (String)

        The Amazon Machine Image (AMI) ID used for instances launched in the compute environment. This parameter is overridden by the imageIdOverride member of the Ec2Configuration structure.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
        Note: The AMI that you choose for a compute environment must match the architecture of the instance types that you intend to use for that compute environment. For example, if your compute environment uses A1 instance types, the compute resource AMI that you choose must support ARM instances. Amazon ECS vends both x86 and ARM versions of the Amazon ECS-optimized Amazon Linux 2 AMI. For more information, see Amazon ECS-optimized Amazon Linux 2 AMI in the Amazon Elastic Container Service Developer Guide.
      • subnetsrequired — (Array<String>)

        The VPC subnets where the compute resources are launched. These subnets must be within the same VPC. Fargate compute resources can contain up to 16 subnets. For more information, see VPCs and subnets in the Amazon VPC User Guide.

        Note: Batch on Amazon EC2 and Batch on Amazon EKS support Local Zones. For more information, see Local Zones in the Amazon EC2 User Guide for Linux Instances, Amazon EKS and Amazon Web Services Local Zones in the Amazon EKS User Guide and Amazon ECS clusters in Local Zones, Wavelength Zones, and Amazon Web Services Outposts in the Amazon ECS Developer Guide. Batch on Fargate doesn't currently support Local Zones.
      • securityGroupIds — (Array<String>)

        The Amazon EC2 security groups that are associated with instances launched in the compute environment. One or more security groups must be specified, either in securityGroupIds or using a launch template referenced in launchTemplate. This parameter is required for jobs that are running on Fargate resources and must contain at least one security group. Fargate doesn't support launch templates. If security groups are specified using both securityGroupIds and launchTemplate, the values in securityGroupIds are used.

      • ec2KeyPair — (String)

        The Amazon EC2 key pair that's used for instances launched in the compute environment. You can use this key pair to log in to your instances with SSH.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
      • instanceRole — (String)

        The Amazon ECS instance profile applied to Amazon EC2 instances in a compute environment. This parameter is required for Amazon EC2 instances types. You can specify the short name or full Amazon Resource Name (ARN) of an instance profile. For example, ecsInstanceRole or arn:aws:iam::<aws_account_id>:instance-profile/ecsInstanceRole . For more information, see Amazon ECS instance role in the Batch User Guide.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
      • tags — (map<String>)

        Key-value pair tags to be applied to Amazon EC2 resources that are launched in the compute environment. For Batch, these take the form of "String1": "String2", where String1 is the tag key and String2 is the tag value-for example, { "Name": "Batch Instance - C4OnDemand" }. This is helpful for recognizing your Batch instances in the Amazon EC2 console. Updating these tags requires an infrastructure update to the compute environment. For more information, see Updating compute environments in the Batch User Guide. These tags aren't seen when using the Batch ListTagsForResource API operation.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
      • placementGroup — (String)

        The Amazon EC2 placement group to associate with your compute resources. If you intend to submit multi-node parallel jobs to your compute environment, you should consider creating a cluster placement group and associate it with your compute resources. This keeps your multi-node parallel job on a logical grouping of instances within a single Availability Zone with high network flow potential. For more information, see Placement groups in the Amazon EC2 User Guide for Linux Instances.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
      • bidPercentage — (Integer)

        The maximum percentage that a Spot Instance price can be when compared with the On-Demand price for that instance type before instances are launched. For example, if your maximum percentage is 20%, then the Spot price must be less than 20% of the current On-Demand price for that Amazon EC2 instance. You always pay the lowest (market) price and never more than your maximum percentage. If you leave this field empty, the default value is 100% of the On-Demand price. For most use cases, we recommend leaving this field empty.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
      • spotIamFleetRole — (String)

        The Amazon Resource Name (ARN) of the Amazon EC2 Spot Fleet IAM role applied to a SPOT compute environment. This role is required if the allocation strategy set to BEST_FIT or if the allocation strategy isn't specified. For more information, see Amazon EC2 spot fleet role in the Batch User Guide.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.

        To tag your Spot Instances on creation, the Spot Fleet IAM role specified here must use the newer AmazonEC2SpotFleetTaggingRole managed policy. The previously recommended AmazonEC2SpotFleetRole managed policy doesn't have the required permissions to tag Spot Instances. For more information, see Spot instances not tagged on creation in the Batch User Guide.

      • launchTemplate — (map)

        The launch template to use for your compute resources. Any other compute resource parameters that you specify in a CreateComputeEnvironment API operation override the same parameters in the launch template. You must specify either the launch template ID or launch template name in the request, but not both. For more information, see Launch template support in the Batch User Guide.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
        • launchTemplateId — (String)

          The ID of the launch template.

        • launchTemplateName — (String)

          The name of the launch template.

        • version — (String)

          The version number of the launch template, $Latest, or $Default.

          If the value is $Latest, the latest version of the launch template is used. If the value is $Default, the default version of the launch template is used.

          If the AMI ID that's used in a compute environment is from the launch template, the AMI isn't changed when the compute environment is updated. It's only changed if the updateToLatestImageVersion parameter for the compute environment is set to true. During an infrastructure update, if either $Latest or $Default is specified, Batch re-evaluates the launch template version, and it might use a different version of the launch template. This is the case even if the launch template isn't specified in the update. When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the Batch User Guide.

          Default: $Default.

      • ec2Configuration — (Array<map>)

        Provides information that's used to select Amazon Machine Images (AMIs) for Amazon EC2 instances in the compute environment. If Ec2Configuration isn't specified, the default is ECS_AL2.

        One or two values can be provided.

        Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
        • imageTyperequired — (String)

          The image type to match with the instance type to select an AMI. The supported values are different for ECS and EKS resources.

          ECS

          If the imageIdOverride parameter isn't specified, then a recent Amazon ECS-optimized Amazon Linux 2 AMI (ECS_AL2) is used. If a new image type is specified in an update, but neither an imageId nor a imageIdOverride parameter is specified, then the latest Amazon ECS optimized AMI for that image type that's supported by Batch is used.

          ECS_AL2

          Amazon Linux 2: Default for all non-GPU instance families.

          ECS_AL2_NVIDIA

          Amazon Linux 2 (GPU): Default for all GPU instance families (for example P4 and G4) and can be used for all non Amazon Web Services Graviton-based instance types.

          ECS_AL2023

          Amazon Linux 2023: Batch supports Amazon Linux 2023.

          Note: Amazon Linux 2023 does not support A1 instances.
          ECS_AL1

          Amazon Linux. Amazon Linux has reached the end-of-life of standard support. For more information, see Amazon Linux AMI.

          EKS

          If the imageIdOverride parameter isn't specified, then a recent Amazon EKS-optimized Amazon Linux AMI (EKS_AL2) is used. If a new image type is specified in an update, but neither an imageId nor a imageIdOverride parameter is specified, then the latest Amazon EKS optimized AMI for that image type that Batch supports is used.

          EKS_AL2

          Amazon Linux 2: Default for all non-GPU instance families.

          EKS_AL2_NVIDIA

          Amazon Linux 2 (accelerated): Default for all GPU instance families (for example, P4 and G4) and can be used for all non Amazon Web Services Graviton-based instance types.

        • imageIdOverride — (String)

          The AMI ID used for instances launched in the compute environment that match the image type. This setting overrides the imageId set in the computeResource object.

          Note: The AMI that you choose for a compute environment must match the architecture of the instance types that you intend to use for that compute environment. For example, if your compute environment uses A1 instance types, the compute resource AMI that you choose must support ARM instances. Amazon ECS vends both x86 and ARM versions of the Amazon ECS-optimized Amazon Linux 2 AMI. For more information, see Amazon ECS-optimized Amazon Linux 2 AMI in the Amazon Elastic Container Service Developer Guide.
        • imageKubernetesVersion — (String)

          The Kubernetes version for the compute environment. If you don't specify a value, the latest version that Batch supports is used.

    • serviceRole — (String)

      The full Amazon Resource Name (ARN) of the IAM role that allows Batch to make calls to other Amazon Web Services services on your behalf. For more information, see Batch service IAM role in the Batch User Guide.

      If your account already created the Batch service-linked role, that role is used by default for your compute environment unless you specify a different role here. If the Batch service-linked role doesn't exist in your account, and no role is specified here, the service attempts to create the Batch service-linked role in your account.

      If your specified role has a path other than /, then you must specify either the full role ARN (recommended) or prefix the role name with the path. For example, if a role with the name bar has a path of /foo/, specify /foo/bar as the role name. For more information, see Friendly names and paths in the IAM User Guide.

      Note: Depending on how you created your Batch service role, its ARN might contain the service-role path prefix. When you only specify the name of the service role, Batch assumes that your ARN doesn't use the service-role path prefix. Because of this, we recommend that you specify the full ARN of your service role when you create compute environments.
    • tags — (map<String>)

      The tags that you apply to the compute environment to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see Tagging Amazon Web Services Resources in Amazon Web Services General Reference.

      These tags can be updated or removed using the TagResource and UntagResource API operations. These tags don't propagate to the underlying compute resources.

    • eksConfiguration — (map)

      The details for the Amazon EKS cluster that supports the compute environment.

      • eksClusterArnrequired — (String)

        The Amazon Resource Name (ARN) of the Amazon EKS cluster. An example is arn:aws:eks:us-east-1:123456789012:cluster/ClusterForBatch .

      • kubernetesNamespacerequired — (String)

        The namespace of the Amazon EKS cluster. Batch manages pods in this namespace. The value can't left empty or null. It must be fewer than 64 characters long, can't be set to default, can't start with "kube-," and must match this regular expression: ^a-z0-9?$. For more information, see Namespaces in the Kubernetes documentation.

    • context — (String)

      Reserved.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • computeEnvironmentName — (String)

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

      • computeEnvironmentArn — (String)

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

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

createJobQueue(params = {}, callback) ⇒ AWS.Request

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.

Service Reference:

Examples:

To create a job queue with a single compute environment


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

 var params = {
  computeEnvironmentOrder: [
     {
    computeEnvironment: "M4Spot", 
    order: 1
   }
  ], 
  jobQueueName: "LowPriority", 
  priority: 1, 
  state: "ENABLED"
 };
 batch.createJobQueue(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    jobQueueArn: "arn:aws:batch:us-east-1:012345678910:job-queue/LowPriority", 
    jobQueueName: "LowPriority"
   }
   */
 });

To create a job queue with multiple compute environments


/* 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. */

 var params = {
  computeEnvironmentOrder: [
     {
    computeEnvironment: "C4OnDemand", 
    order: 1
   }, 
     {
    computeEnvironment: "M4Spot", 
    order: 2
   }
  ], 
  jobQueueName: "HighPriority", 
  priority: 10, 
  state: "ENABLED"
 };
 batch.createJobQueue(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    jobQueueArn: "arn:aws:batch:us-east-1:012345678910:job-queue/HighPriority", 
    jobQueueName: "HighPriority"
   }
   */
 });

Calling the createJobQueue operation

var params = {
  computeEnvironmentOrder: [ /* required */
    {
      computeEnvironment: 'STRING_VALUE', /* required */
      order: 'NUMBER_VALUE' /* required */
    },
    /* more items */
  ],
  jobQueueName: 'STRING_VALUE', /* required */
  priority: 'NUMBER_VALUE', /* required */
  jobStateTimeLimitActions: [
    {
      action: CANCEL, /* required */
      maxTimeSeconds: 'NUMBER_VALUE', /* required */
      reason: 'STRING_VALUE', /* required */
      state: RUNNABLE /* required */
    },
    /* more items */
  ],
  schedulingPolicyArn: 'STRING_VALUE',
  state: ENABLED | DISABLED,
  tags: {
    '<TagKey>': 'STRING_VALUE',
    /* '<TagKey>': ... */
  }
};
batch.createJobQueue(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • jobQueueName — (String)

      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.

      Possible values include:
      • "ENABLED"
      • "DISABLED"
    • 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)

      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 — (Array<map>)

      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.
      • orderrequired — (Integer)

        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.

      • computeEnvironmentrequired — (String)

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

    • tags — (map<String>)

      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.

    • jobStateTimeLimitActions — (Array<map>)

      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.

      • reasonrequired — (String)

        The reason to log for the action being taken.

      • staterequired — (String)

        The state of the job needed to trigger the action. The only supported value is RUNNABLE.

        Possible values include:
        • "RUNNABLE"
      • maxTimeSecondsrequired — (Integer)

        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).

      • actionrequired — (String)

        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.

        Possible values include:
        • "CANCEL"

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • jobQueueName — (String)

        The name of the job queue.

      • jobQueueArn — (String)

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

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

createSchedulingPolicy(params = {}, callback) ⇒ AWS.Request

Creates an Batch scheduling policy.

Service Reference:

Examples:

Calling the createSchedulingPolicy operation

var params = {
  name: 'STRING_VALUE', /* required */
  fairsharePolicy: {
    computeReservation: 'NUMBER_VALUE',
    shareDecaySeconds: 'NUMBER_VALUE',
    shareDistribution: [
      {
        shareIdentifier: 'STRING_VALUE', /* required */
        weightFactor: 'NUMBER_VALUE'
      },
      /* more items */
    ]
  },
  tags: {
    '<TagKey>': 'STRING_VALUE',
    /* '<TagKey>': ... */
  }
};
batch.createSchedulingPolicy(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • name — (String)

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

    • fairsharePolicy — (map)

      The fair share policy of the scheduling policy.

      • shareDecaySeconds — (Integer)

        The amount of time (in seconds) to use to calculate a fair share percentage for each fair share identifier in use. A value of zero (0) indicates that only current usage is measured. The decay allows for more recently run jobs to have more weight than jobs that ran earlier. The maximum supported value is 604800 (1 week).

      • computeReservation — (Integer)

        A value used to reserve some of the available maximum vCPU for fair share identifiers that aren't already used.

        The reserved ratio is (computeReservation/100)^ActiveFairShares where ActiveFairShares is the number of active fair share identifiers.

        For example, a computeReservation value of 50 indicates that Batch reserves 50% of the maximum available vCPU if there's only one fair share identifier. It reserves 25% if there are two fair share identifiers. It reserves 12.5% if there are three fair share identifiers. A computeReservation value of 25 indicates that Batch should reserve 25% of the maximum available vCPU if there's only one fair share identifier, 6.25% if there are two fair share identifiers, and 1.56% if there are three fair share identifiers.

        The minimum value is 0 and the maximum value is 99.

      • shareDistribution — (Array<map>)

        An array of SharedIdentifier objects that contain the weights for the fair share identifiers for the fair share policy. Fair share identifiers that aren't included have a default weight of 1.0.

        • shareIdentifierrequired — (String)

          A fair share identifier or fair share identifier prefix. If the string ends with an asterisk (), this entry specifies the weight factor to use for fair share identifiers that start with that prefix. The list of fair share identifiers in a fair share policy can't overlap. For example, you can't have one that specifies a shareIdentifier of UserA* and another that specifies a shareIdentifier of UserA-1.

          There can be no more than 500 fair share identifiers active in a job queue.

          The string is limited to 255 alphanumeric characters, and can be followed by an asterisk ().

        • weightFactor — (Float)

          The weight factor for the fair share identifier. The default value is 1.0. A lower value has a higher priority for compute resources. For example, jobs that use a share identifier with a weight factor of 0.125 (1/8) get 8 times the compute resources of jobs that use a share identifier with a weight factor of 1.

          The smallest supported value is 0.0001, and the largest supported value is 999.9999.

    • tags — (map<String>)

      The tags that you apply to the scheduling policy to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see Tagging Amazon Web Services Resources in Amazon Web Services General Reference.

      These tags can be updated or removed using the TagResource and UntagResource API operations.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • name — (String)

        The name of the scheduling policy.

      • arn — (String)

        The Amazon Resource Name (ARN) of the scheduling policy. The format is aws:Partition:batch:Region:Account:scheduling-policy/Name . For example, aws:aws:batch:us-west-2:123456789012:scheduling-policy/MySchedulingPolicy.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

deleteComputeEnvironment(params = {}, callback) ⇒ AWS.Request

Deletes an Batch compute environment.

Before you can delete a compute environment, you must set its state to DISABLED with the UpdateComputeEnvironment API operation and disassociate it from any job queues with the UpdateJobQueue API operation. Compute environments that use Fargate resources must terminate all active jobs on that compute environment before deleting the compute environment. If this isn't done, the compute environment enters an invalid state.

Service Reference:

Examples:

To delete a compute environment


/* This example deletes the P2OnDemand compute environment. */

 var params = {
  computeEnvironment: "P2OnDemand"
 };
 batch.deleteComputeEnvironment(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
   }
   */
 });

Calling the deleteComputeEnvironment operation

var params = {
  computeEnvironment: 'STRING_VALUE' /* required */
};
batch.deleteComputeEnvironment(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • computeEnvironment — (String)

      The name or Amazon Resource Name (ARN) of the compute environment to delete.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

deleteJobQueue(params = {}, callback) ⇒ AWS.Request

Deletes the specified job queue. You must first disable submissions for a queue with the UpdateJobQueue operation. All jobs in the queue are eventually terminated when you delete a job queue. The jobs are terminated at a rate of about 16 jobs each second.

It's not necessary to disassociate compute environments from a queue before submitting a DeleteJobQueue request.

Service Reference:

Examples:

To delete a job queue


/* This example deletes the GPGPU job queue. */

 var params = {
  jobQueue: "GPGPU"
 };
 batch.deleteJobQueue(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
   }
   */
 });

Calling the deleteJobQueue operation

var params = {
  jobQueue: 'STRING_VALUE' /* required */
};
batch.deleteJobQueue(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • jobQueue — (String)

      The short name or full Amazon Resource Name (ARN) of the queue to delete.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

deleteSchedulingPolicy(params = {}, callback) ⇒ AWS.Request

Deletes the specified scheduling policy.

You can't delete a scheduling policy that's used in any job queues.

Service Reference:

Examples:

Calling the deleteSchedulingPolicy operation

var params = {
  arn: 'STRING_VALUE' /* required */
};
batch.deleteSchedulingPolicy(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • arn — (String)

      The Amazon Resource Name (ARN) of the scheduling policy to delete.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

deregisterJobDefinition(params = {}, callback) ⇒ AWS.Request

Deregisters an Batch job definition. Job definitions are permanently deleted after 180 days.

Service Reference:

Examples:

To deregister a job definition


/* This example deregisters a job definition called sleep10. */

 var params = {
  jobDefinition: "sleep10"
 };
 batch.deregisterJobDefinition(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
   }
   */
 });

Calling the deregisterJobDefinition operation

var params = {
  jobDefinition: 'STRING_VALUE' /* required */
};
batch.deregisterJobDefinition(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • jobDefinition — (String)

      The name and revision (name:revision) or full Amazon Resource Name (ARN) of the job definition to deregister.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

describeComputeEnvironments(params = {}, callback) ⇒ AWS.Request

Describes one or more of your compute environments.

If you're using an unmanaged compute environment, you can use the DescribeComputeEnvironment operation to determine the ecsClusterArn that you launch your Amazon ECS container instances into.

Service Reference:

Examples:

To describe a compute environment


/* This example describes the P2OnDemand compute environment. */

 var params = {
  computeEnvironments: [
     "P2OnDemand"
  ]
 };
 batch.describeComputeEnvironments(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    computeEnvironments: [
       {
      type: "MANAGED", 
      computeEnvironmentArn: "arn:aws:batch:us-east-1:012345678910:compute-environment/P2OnDemand", 
      computeEnvironmentName: "P2OnDemand", 
      computeResources: {
       type: "EC2", 
       desiredvCpus: 48, 
       ec2KeyPair: "id_rsa", 
       instanceRole: "ecsInstanceRole", 
       instanceTypes: [
          "p2"
       ], 
       maxvCpus: 128, 
       minvCpus: 0, 
       securityGroupIds: [
          "sg-cf5093b2"
       ], 
       subnets: [
          "subnet-220c0e0a", 
          "subnet-1a95556d", 
          "subnet-978f6dce"
       ], 
       tags: {
        "Name": "Batch Instance - P2OnDemand"
       }
      }, 
      ecsClusterArn: "arn:aws:ecs:us-east-1:012345678910:cluster/P2OnDemand_Batch_2c06f29d-d1fe-3a49-879d-42394c86effc", 
      serviceRole: "arn:aws:iam::012345678910:role/AWSBatchServiceRole", 
      state: "ENABLED", 
      status: "VALID", 
      statusReason: "ComputeEnvironment Healthy"
     }
    ]
   }
   */
 });

Calling the describeComputeEnvironments operation

var params = {
  computeEnvironments: [
    'STRING_VALUE',
    /* more items */
  ],
  maxResults: 'NUMBER_VALUE',
  nextToken: 'STRING_VALUE'
};
batch.describeComputeEnvironments(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • computeEnvironments — (Array<String>)

      A list of up to 100 compute environment names or full Amazon Resource Name (ARN) entries.

    • maxResults — (Integer)

      The maximum number of cluster results returned by DescribeComputeEnvironments in paginated output. When this parameter is used, DescribeComputeEnvironments only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another DescribeComputeEnvironments request with the returned nextToken value. This value can be between 1 and 100. If this parameter isn't used, then DescribeComputeEnvironments returns up to 100 results and a nextToken value if applicable.

    • nextToken — (String)

      The nextToken value returned from a previous paginated DescribeComputeEnvironments request where maxResults was used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the nextToken value. This value is null when there are no more results to return.

      Note: Treat this token as an opaque identifier that's only used to retrieve the next items in a list and not for other programmatic purposes.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • computeEnvironments — (Array<map>)

        The list of compute environments.

        • computeEnvironmentNamerequired — (String)

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

        • computeEnvironmentArnrequired — (String)

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

        • unmanagedvCpus — (Integer)

          The maximum number of VCPUs expected to be used for an unmanaged compute environment.

        • ecsClusterArn — (String)

          The Amazon Resource Name (ARN) of the underlying Amazon ECS cluster that the compute environment uses.

        • tags — (map<String>)

          The tags applied to the compute environment.

        • type — (String)

          The type of the compute environment: MANAGED or UNMANAGED. For more information, see Compute environments in the Batch User Guide.

          Possible values include:
          • "MANAGED"
          • "UNMANAGED"
        • state — (String)

          The state of the compute environment. The valid values are ENABLED or DISABLED.

          If the state is ENABLED, then the Batch scheduler can attempt to place jobs from an associated job queue on the compute resources within the environment. If the compute environment is managed, then it can scale its instances out or in automatically based on the job queue demand.

          If the state is DISABLED, then the Batch scheduler doesn't attempt to place jobs within the environment. Jobs in a STARTING or RUNNING state continue to progress normally. Managed compute environments in the DISABLED state don't scale out.

          Note: Compute environments in a DISABLED state may continue to incur billing charges. To prevent additional charges, turn off and then delete the compute environment. For more information, see State in the Batch User Guide.

          When an instance is idle, the instance scales down to the minvCpus value. However, the instance size doesn't change. For example, consider a c5.8xlarge instance with a minvCpus value of 4 and a desiredvCpus value of 36. This instance doesn't scale down to a c5.large instance.

          Possible values include:
          • "ENABLED"
          • "DISABLED"
        • status — (String)

          The current status of the compute environment (for example, CREATING or VALID).

          Possible values include:
          • "CREATING"
          • "UPDATING"
          • "DELETING"
          • "DELETED"
          • "VALID"
          • "INVALID"
        • statusReason — (String)

          A short, human-readable string to provide additional details for the current status of the compute environment.

        • computeResources — (map)

          The compute resources defined for the compute environment. For more information, see Compute environments in the Batch User Guide.

          • typerequired — (String)

            The type of compute environment: EC2, SPOT, FARGATE, or FARGATE_SPOT. For more information, see Compute environments in the Batch User Guide.

            If you choose SPOT, you must also specify an Amazon EC2 Spot Fleet role with the spotIamFleetRole parameter. For more information, see Amazon EC2 spot fleet role in the Batch User Guide.

            Possible values include:
            • "EC2"
            • "SPOT"
            • "FARGATE"
            • "FARGATE_SPOT"
          • allocationStrategy — (String)

            The allocation strategy to use for the compute resource if not enough instances of the best fitting instance type can be allocated. This might be because of availability of the instance type in the Region or Amazon EC2 service limits. For more information, see Allocation strategies in the Batch User Guide.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
            BEST_FIT (default)

            Batch selects an instance type that best fits the needs of the jobs with a preference for the lowest-cost instance type. If additional instances of the selected instance type aren't available, Batch waits for the additional instances to be available. If there aren't enough instances available or the user is reaching Amazon EC2 service limits, additional jobs aren't run until the currently running jobs are completed. This allocation strategy keeps costs lower but can limit scaling. If you're using Spot Fleets with BEST_FIT, the Spot Fleet IAM Role must be specified. Compute resources that use a BEST_FIT allocation strategy don't support infrastructure updates and can't update some parameters. For more information, see Updating compute environments in the Batch User Guide.

            BEST_FIT_PROGRESSIVE

            Batch selects additional instance types that are large enough to meet the requirements of the jobs in the queue. Its preference is for instance types with lower cost vCPUs. If additional instances of the previously selected instance types aren't available, Batch selects new instance types.

            SPOT_CAPACITY_OPTIMIZED

            Batch selects one or more instance types that are large enough to meet the requirements of the jobs in the queue. Its preference is for instance types that are less likely to be interrupted. This allocation strategy is only available for Spot Instance compute resources.

            SPOT_PRICE_CAPACITY_OPTIMIZED

            The price and capacity optimized allocation strategy looks at both price and capacity to select the Spot Instance pools that are the least likely to be interrupted and have the lowest possible price. This allocation strategy is only available for Spot Instance compute resources.

            With BEST_FIT_PROGRESSIVE,SPOT_CAPACITY_OPTIMIZED and SPOT_PRICE_CAPACITY_OPTIMIZED (recommended) strategies using On-Demand or Spot Instances, and the BEST_FIT strategy using Spot Instances, Batch might need to exceed maxvCpus to meet your capacity requirements. In this event, Batch never exceeds maxvCpus by more than a single instance.

            Possible values include:
            • "BEST_FIT"
            • "BEST_FIT_PROGRESSIVE"
            • "SPOT_CAPACITY_OPTIMIZED"
            • "SPOT_PRICE_CAPACITY_OPTIMIZED"
          • minvCpus — (Integer)

            The minimum number of vCPUs that a compute environment should maintain (even if the compute environment is DISABLED).

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
          • maxvCpusrequired — (Integer)

            The maximum number of vCPUs that a compute environment can support.

            Note: With BEST_FIT_PROGRESSIVE,SPOT_CAPACITY_OPTIMIZED and SPOT_PRICE_CAPACITY_OPTIMIZED (recommended) strategies using On-Demand or Spot Instances, and the BEST_FIT strategy using Spot Instances, Batch might need to exceed maxvCpus to meet your capacity requirements. In this event, Batch never exceeds maxvCpus by more than a single instance.
          • desiredvCpus — (Integer)

            The desired number of vCPUS in the compute environment. Batch modifies this value between the minimum and maximum values based on job queue demand.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
          • instanceTypes — (Array<String>)

            The instances types that can be launched. You can specify instance families to launch any instance type within those families (for example, c5 or p3), or you can specify specific sizes within a family (such as c5.8xlarge). You can also choose optimal to select instance types (from the C4, M4, and R4 instance families) that match the demand of your job queues.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
            Note: When you create a compute environment, the instance types that you select for the compute environment must share the same architecture. For example, you can't mix x86 and ARM instances in the same compute environment.
            Note: Currently, optimal uses instance types from the C4, M4, and R4 instance families. In Regions that don't have instance types from those instance families, instance types from the C5, M5, and R5 instance families are used.
          • imageId — (String)

            The Amazon Machine Image (AMI) ID used for instances launched in the compute environment. This parameter is overridden by the imageIdOverride member of the Ec2Configuration structure.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
            Note: The AMI that you choose for a compute environment must match the architecture of the instance types that you intend to use for that compute environment. For example, if your compute environment uses A1 instance types, the compute resource AMI that you choose must support ARM instances. Amazon ECS vends both x86 and ARM versions of the Amazon ECS-optimized Amazon Linux 2 AMI. For more information, see Amazon ECS-optimized Amazon Linux 2 AMI in the Amazon Elastic Container Service Developer Guide.
          • subnetsrequired — (Array<String>)

            The VPC subnets where the compute resources are launched. These subnets must be within the same VPC. Fargate compute resources can contain up to 16 subnets. For more information, see VPCs and subnets in the Amazon VPC User Guide.

            Note: Batch on Amazon EC2 and Batch on Amazon EKS support Local Zones. For more information, see Local Zones in the Amazon EC2 User Guide for Linux Instances, Amazon EKS and Amazon Web Services Local Zones in the Amazon EKS User Guide and Amazon ECS clusters in Local Zones, Wavelength Zones, and Amazon Web Services Outposts in the Amazon ECS Developer Guide. Batch on Fargate doesn't currently support Local Zones.
          • securityGroupIds — (Array<String>)

            The Amazon EC2 security groups that are associated with instances launched in the compute environment. One or more security groups must be specified, either in securityGroupIds or using a launch template referenced in launchTemplate. This parameter is required for jobs that are running on Fargate resources and must contain at least one security group. Fargate doesn't support launch templates. If security groups are specified using both securityGroupIds and launchTemplate, the values in securityGroupIds are used.

          • ec2KeyPair — (String)

            The Amazon EC2 key pair that's used for instances launched in the compute environment. You can use this key pair to log in to your instances with SSH.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
          • instanceRole — (String)

            The Amazon ECS instance profile applied to Amazon EC2 instances in a compute environment. This parameter is required for Amazon EC2 instances types. You can specify the short name or full Amazon Resource Name (ARN) of an instance profile. For example, ecsInstanceRole or arn:aws:iam::<aws_account_id>:instance-profile/ecsInstanceRole . For more information, see Amazon ECS instance role in the Batch User Guide.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
          • tags — (map<String>)

            Key-value pair tags to be applied to Amazon EC2 resources that are launched in the compute environment. For Batch, these take the form of "String1": "String2", where String1 is the tag key and String2 is the tag value-for example, { "Name": "Batch Instance - C4OnDemand" }. This is helpful for recognizing your Batch instances in the Amazon EC2 console. Updating these tags requires an infrastructure update to the compute environment. For more information, see Updating compute environments in the Batch User Guide. These tags aren't seen when using the Batch ListTagsForResource API operation.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
          • placementGroup — (String)

            The Amazon EC2 placement group to associate with your compute resources. If you intend to submit multi-node parallel jobs to your compute environment, you should consider creating a cluster placement group and associate it with your compute resources. This keeps your multi-node parallel job on a logical grouping of instances within a single Availability Zone with high network flow potential. For more information, see Placement groups in the Amazon EC2 User Guide for Linux Instances.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
          • bidPercentage — (Integer)

            The maximum percentage that a Spot Instance price can be when compared with the On-Demand price for that instance type before instances are launched. For example, if your maximum percentage is 20%, then the Spot price must be less than 20% of the current On-Demand price for that Amazon EC2 instance. You always pay the lowest (market) price and never more than your maximum percentage. If you leave this field empty, the default value is 100% of the On-Demand price. For most use cases, we recommend leaving this field empty.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
          • spotIamFleetRole — (String)

            The Amazon Resource Name (ARN) of the Amazon EC2 Spot Fleet IAM role applied to a SPOT compute environment. This role is required if the allocation strategy set to BEST_FIT or if the allocation strategy isn't specified. For more information, see Amazon EC2 spot fleet role in the Batch User Guide.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.

            To tag your Spot Instances on creation, the Spot Fleet IAM role specified here must use the newer AmazonEC2SpotFleetTaggingRole managed policy. The previously recommended AmazonEC2SpotFleetRole managed policy doesn't have the required permissions to tag Spot Instances. For more information, see Spot instances not tagged on creation in the Batch User Guide.

          • launchTemplate — (map)

            The launch template to use for your compute resources. Any other compute resource parameters that you specify in a CreateComputeEnvironment API operation override the same parameters in the launch template. You must specify either the launch template ID or launch template name in the request, but not both. For more information, see Launch template support in the Batch User Guide.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
            • launchTemplateId — (String)

              The ID of the launch template.

            • launchTemplateName — (String)

              The name of the launch template.

            • version — (String)

              The version number of the launch template, $Latest, or $Default.

              If the value is $Latest, the latest version of the launch template is used. If the value is $Default, the default version of the launch template is used.

              If the AMI ID that's used in a compute environment is from the launch template, the AMI isn't changed when the compute environment is updated. It's only changed if the updateToLatestImageVersion parameter for the compute environment is set to true. During an infrastructure update, if either $Latest or $Default is specified, Batch re-evaluates the launch template version, and it might use a different version of the launch template. This is the case even if the launch template isn't specified in the update. When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the Batch User Guide.

              Default: $Default.

          • ec2Configuration — (Array<map>)

            Provides information that's used to select Amazon Machine Images (AMIs) for Amazon EC2 instances in the compute environment. If Ec2Configuration isn't specified, the default is ECS_AL2.

            One or two values can be provided.

            Note: This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
            • imageTyperequired — (String)

              The image type to match with the instance type to select an AMI. The supported values are different for ECS and EKS resources.

              ECS

              If the imageIdOverride parameter isn't specified, then a recent Amazon ECS-optimized Amazon Linux 2 AMI (ECS_AL2) is used. If a new image type is specified in an update, but neither an imageId nor a imageIdOverride parameter is specified, then the latest Amazon ECS optimized AMI for that image type that's supported by Batch is used.

              ECS_AL2

              Amazon Linux 2: Default for all non-GPU instance families.

              ECS_AL2_NVIDIA