[ aws . batch ]

register-job-definition

Description

Registers an AWS Batch job definition.

See also: AWS API Documentation

See ‘aws help’ for descriptions of global parameters.

Synopsis

  register-job-definition
--job-definition-name <value>
--type <value>
[--parameters <value>]
[--container-properties <value>]
[--node-properties <value>]
[--retry-strategy <value>]
[--timeout <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--cli-auto-prompt <value>]

Options

--job-definition-name (string)

The name of the job definition to register. Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.

--type (string)

The type of job definition.

Possible values:

  • container

  • multinode

--parameters (map)

Default parameter substitution placeholders to set in the job definition. Parameters are specified as a key-value pair mapping. Parameters in a SubmitJob request override any corresponding parameter defaults from the job definition.

key -> (string)

value -> (string)

Shorthand Syntax:

KeyName1=string,KeyName2=string

JSON Syntax:

{"string": "string"
  ...}

--container-properties (structure)

An object with various properties specific to single-node container-based jobs. If the job definition’s type parameter is container , then you must specify either containerProperties or nodeProperties .

image -> (string)

The image used to start a container. This string is passed directly to the Docker daemon. Images in the Docker Hub registry are available by default. Other repositories are specified with `` repository-url /image :tag `` . Up to 255 letters (uppercase and lowercase), numbers, hyphens, underscores, colons, periods, forward slashes, and number signs are allowed. This parameter maps to Image in the Create a container section of the Docker Remote API and the IMAGE parameter of docker run .

  • Images in Amazon ECR repositories use the full registry and repository URI (for example, 012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name> ).

  • Images in official repositories on Docker Hub use a single name (for example, ubuntu or mongo ).

  • Images in other repositories on Docker Hub are qualified with an organization name (for example, amazon/amazon-ecs-agent ).

  • Images in other online repositories are qualified further by a domain name (for example, quay.io/assemblyline/ubuntu ).

vcpus -> (integer)

The number of vCPUs reserved for the container. This parameter maps to CpuShares in the Create a container section of the Docker Remote API and the --cpu-shares option to docker run . Each vCPU is equivalent to 1,024 CPU shares. You must specify at least one vCPU.

memory -> (integer)

The hard limit (in MiB) of memory to present to the container. If your container attempts to exceed the memory specified here, the container is killed. This parameter maps to Memory in the Create a container section of the Docker Remote API and the --memory option to docker run . You must specify at least 4 MiB of memory for a job.

Note

If you are trying to maximize your resource utilization by providing your jobs as much memory as possible for a particular instance type, see Memory Management in the AWS Batch User Guide .

command -> (list)

The command that is passed to the container. This parameter maps to Cmd in the Create a container section of the Docker Remote API and the COMMAND parameter to docker run . For more information, see https://docs.docker.com/engine/reference/builder/#cmd .

(string)

jobRoleArn -> (string)

The Amazon Resource Name (ARN) of the IAM role that the container can assume for AWS permissions.

volumes -> (list)

A list of data volumes used in a job.

(structure)

A data volume used in a job’s container properties.

host -> (structure)

The contents of the host parameter determine whether your data volume persists on the host container instance and where it is stored. If the host parameter is empty, then the Docker daemon assigns a host path for your data volume. However, the data is not guaranteed to persist after the containers associated with it stop running.

sourcePath -> (string)

The path on the host container instance that is presented to the container. If this parameter is empty, then the Docker daemon has assigned a host path for you. If this parameter contains a file location, then the data volume persists at the specified location on the host container instance until you delete it manually. If the source path location does not exist on the host container instance, the Docker daemon creates it. If the location does exist, the contents of the source path folder are exported.

name -> (string)

The name of the volume. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed. This name is referenced in the sourceVolume parameter of container definition mountPoints .

environment -> (list)

The environment variables to pass to a container. This parameter maps to Env in the Create a container section of the Docker Remote API and the --env option to docker run .

Warning

We do not recommend using plaintext environment variables for sensitive information, such as credential data.

Note

Environment variables must not start with AWS_BATCH ; this naming convention is reserved for variables that are set by the AWS Batch service.

(structure)

A key-value pair object.

name -> (string)

The name of the key-value pair. For environment variables, this is the name of the environment variable.

value -> (string)

The value of the key-value pair. For environment variables, this is the value of the environment variable.

mountPoints -> (list)

The mount points for data volumes in your container. This parameter maps to Volumes in the Create a container section of the Docker Remote API and the --volume option to docker run .

(structure)

Details on a Docker volume mount point that is used in a job’s container properties. This parameter maps to Volumes in the Create a container section of the Docker Remote API and the --volume option to docker run.

containerPath -> (string)

The path on the container at which to mount the host volume.

readOnly -> (boolean)

If this value is true , the container has read-only access to the volume; otherwise, the container can write to the volume. The default value is false .

sourceVolume -> (string)

The name of the volume to mount.

readonlyRootFilesystem -> (boolean)

When this parameter is true, the container is given read-only access to its root file system. This parameter maps to ReadonlyRootfs in the Create a container section of the Docker Remote API and the --read-only option to docker run .

privileged -> (boolean)

When this parameter is true, the container is given elevated privileges on the host container instance (similar to the root user). This parameter maps to Privileged in the Create a container section of the Docker Remote API and the --privileged option to docker run .

ulimits -> (list)

A list of ulimits to set in the container. This parameter maps to Ulimits in the Create a container section of the Docker Remote API and the --ulimit option to docker run .

(structure)

The ulimit settings to pass to the container.

hardLimit -> (integer)

The hard limit for the ulimit type.

name -> (string)

The type of the ulimit .

softLimit -> (integer)

The soft limit for the ulimit type.

user -> (string)

The user name to use inside the container. This parameter maps to User in the Create a container section of the Docker Remote API and the --user option to docker run .

instanceType -> (string)

The instance type to use for a multi-node parallel job. Currently all node groups in a multi-node parallel job must use the same instance type. This parameter is not valid for single-node container jobs.

resourceRequirements -> (list)

The type and amount of a resource to assign to a container. Currently, the only supported resource is GPU .

(structure)

The type and amount of a resource to assign to a container. Currently, the only supported resource type is GPU .

value -> (string)

The number of physical GPUs to reserve for the container. The number of GPUs reserved for all containers in a job should not exceed the number of available GPUs on the compute resource that the job is launched on.

type -> (string)

The type of resource to assign to a container. Currently, the only supported resource type is GPU .

linuxParameters -> (structure)

Linux-specific modifications that are applied to the container, such as details for device mappings.

devices -> (list)

Any host devices to expose to the container. This parameter maps to Devices in the Create a container section of the Docker Remote API and the --device option to docker run .

(structure)

An object representing a container instance host device.

hostPath -> (string)

The path for the device on the host container instance.

containerPath -> (string)

The path inside the container at which to expose the host device. By default the hostPath value is used.

permissions -> (list)

The explicit permissions to provide to the container for the device. By default, the container has permissions for read , write , and mknod for the device.

(string)

JSON Syntax:

{
  "image": "string",
  "vcpus": integer,
  "memory": integer,
  "command": ["string", ...],
  "jobRoleArn": "string",
  "volumes": [
    {
      "host": {
        "sourcePath": "string"
      },
      "name": "string"
    }
    ...
  ],
  "environment": [
    {
      "name": "string",
      "value": "string"
    }
    ...
  ],
  "mountPoints": [
    {
      "containerPath": "string",
      "readOnly": true|false,
      "sourceVolume": "string"
    }
    ...
  ],
  "readonlyRootFilesystem": true|false,
  "privileged": true|false,
  "ulimits": [
    {
      "hardLimit": integer,
      "name": "string",
      "softLimit": integer
    }
    ...
  ],
  "user": "string",
  "instanceType": "string",
  "resourceRequirements": [
    {
      "value": "string",
      "type": "GPU"
    }
    ...
  ],
  "linuxParameters": {
    "devices": [
      {
        "hostPath": "string",
        "containerPath": "string",
        "permissions": ["READ"|"WRITE"|"MKNOD", ...]
      }
      ...
    ]
  }
}

--node-properties (structure)

An object with various properties specific to multi-node parallel jobs. If you specify node properties for a job, it becomes a multi-node parallel job. For more information, see Multi-node Parallel Jobs in the AWS Batch User Guide . If the job definition’s type parameter is container , then you must specify either containerProperties or nodeProperties .

numNodes -> (integer)

The number of nodes associated with a multi-node parallel job.

mainNode -> (integer)

Specifies the node index for the main node of a multi-node parallel job. This node index value must be fewer than the number of nodes.

nodeRangeProperties -> (list)

A list of node ranges and their properties associated with a multi-node parallel job.

(structure)

An object representing the properties of the node range for a multi-node parallel job.

targetNodes -> (string)

The range of nodes, using node index values. A range of 0:3 indicates nodes with index values of 0 through 3 . If the starting range value is omitted (:n ), then 0 is used to start the range. If the ending range value is omitted (n: ), then the highest possible node index is used to end the range. Your accumulative node ranges must account for all nodes (0:n). You may nest node ranges, for example 0:10 and 4:5, in which case the 4:5 range properties override the 0:10 properties.

container -> (structure)

The container details for the node range.

image -> (string)

The image used to start a container. This string is passed directly to the Docker daemon. Images in the Docker Hub registry are available by default. Other repositories are specified with `` repository-url /image :tag `` . Up to 255 letters (uppercase and lowercase), numbers, hyphens, underscores, colons, periods, forward slashes, and number signs are allowed. This parameter maps to Image in the Create a container section of the Docker Remote API and the IMAGE parameter of docker run .

  • Images in Amazon ECR repositories use the full registry and repository URI (for example, 012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name> ).

  • Images in official repositories on Docker Hub use a single name (for example, ubuntu or mongo ).

  • Images in other repositories on Docker Hub are qualified with an organization name (for example, amazon/amazon-ecs-agent ).

  • Images in other online repositories are qualified further by a domain name (for example, quay.io/assemblyline/ubuntu ).

vcpus -> (integer)

The number of vCPUs reserved for the container. This parameter maps to CpuShares in the Create a container section of the Docker Remote API and the --cpu-shares option to docker run . Each vCPU is equivalent to 1,024 CPU shares. You must specify at least one vCPU.

memory -> (integer)

The hard limit (in MiB) of memory to present to the container. If your container attempts to exceed the memory specified here, the container is killed. This parameter maps to Memory in the Create a container section of the Docker Remote API and the --memory option to docker run . You must specify at least 4 MiB of memory for a job.

Note

If you are trying to maximize your resource utilization by providing your jobs as much memory as possible for a particular instance type, see Memory Management in the AWS Batch User Guide .

command -> (list)

The command that is passed to the container. This parameter maps to Cmd in the Create a container section of the Docker Remote API and the COMMAND parameter to docker run . For more information, see https://docs.docker.com/engine/reference/builder/#cmd .

(string)

jobRoleArn -> (string)

The Amazon Resource Name (ARN) of the IAM role that the container can assume for AWS permissions.

volumes -> (list)

A list of data volumes used in a job.

(structure)

A data volume used in a job’s container properties.

host -> (structure)

The contents of the host parameter determine whether your data volume persists on the host container instance and where it is stored. If the host parameter is empty, then the Docker daemon assigns a host path for your data volume. However, the data is not guaranteed to persist after the containers associated with it stop running.

sourcePath -> (string)

The path on the host container instance that is presented to the container. If this parameter is empty, then the Docker daemon has assigned a host path for you. If this parameter contains a file location, then the data volume persists at the specified location on the host container instance until you delete it manually. If the source path location does not exist on the host container instance, the Docker daemon creates it. If the location does exist, the contents of the source path folder are exported.

name -> (string)

The name of the volume. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed. This name is referenced in the sourceVolume parameter of container definition mountPoints .

environment -> (list)

The environment variables to pass to a container. This parameter maps to Env in the Create a container section of the Docker Remote API and the --env option to docker run .

Warning

We do not recommend using plaintext environment variables for sensitive information, such as credential data.

Note

Environment variables must not start with AWS_BATCH ; this naming convention is reserved for variables that are set by the AWS Batch service.

(structure)

A key-value pair object.

name -> (string)

The name of the key-value pair. For environment variables, this is the name of the environment variable.

value -> (string)

The value of the key-value pair. For environment variables, this is the value of the environment variable.

mountPoints -> (list)

The mount points for data volumes in your container. This parameter maps to Volumes in the Create a container section of the Docker Remote API and the --volume option to docker run .

(structure)

Details on a Docker volume mount point that is used in a job’s container properties. This parameter maps to Volumes in the Create a container section of the Docker Remote API and the --volume option to docker run.

containerPath -> (string)

The path on the container at which to mount the host volume.

readOnly -> (boolean)

If this value is true , the container has read-only access to the volume; otherwise, the container can write to the volume. The default value is false .

sourceVolume -> (string)

The name of the volume to mount.

readonlyRootFilesystem -> (boolean)

When this parameter is true, the container is given read-only access to its root file system. This parameter maps to ReadonlyRootfs in the Create a container section of the Docker Remote API and the --read-only option to docker run .

privileged -> (boolean)

When this parameter is true, the container is given elevated privileges on the host container instance (similar to the root user). This parameter maps to Privileged in the Create a container section of the Docker Remote API and the --privileged option to docker run .

ulimits -> (list)

A list of ulimits to set in the container. This parameter maps to Ulimits in the Create a container section of the Docker Remote API and the --ulimit option to docker run .

(structure)

The ulimit settings to pass to the container.

hardLimit -> (integer)

The hard limit for the ulimit type.

name -> (string)

The type of the ulimit .

softLimit -> (integer)

The soft limit for the ulimit type.

user -> (string)

The user name to use inside the container. This parameter maps to User in the Create a container section of the Docker Remote API and the --user option to docker run .

instanceType -> (string)

The instance type to use for a multi-node parallel job. Currently all node groups in a multi-node parallel job must use the same instance type. This parameter is not valid for single-node container jobs.

resourceRequirements -> (list)

The type and amount of a resource to assign to a container. Currently, the only supported resource is GPU .

(structure)

The type and amount of a resource to assign to a container. Currently, the only supported resource type is GPU .

value -> (string)

The number of physical GPUs to reserve for the container. The number of GPUs reserved for all containers in a job should not exceed the number of available GPUs on the compute resource that the job is launched on.

type -> (string)

The type of resource to assign to a container. Currently, the only supported resource type is GPU .

linuxParameters -> (structure)

Linux-specific modifications that are applied to the container, such as details for device mappings.

devices -> (list)

Any host devices to expose to the container. This parameter maps to Devices in the Create a container section of the Docker Remote API and the --device option to docker run .

(structure)

An object representing a container instance host device.

hostPath -> (string)

The path for the device on the host container instance.

containerPath -> (string)

The path inside the container at which to expose the host device. By default the hostPath value is used.

permissions -> (list)

The explicit permissions to provide to the container for the device. By default, the container has permissions for read , write , and mknod for the device.

(string)

JSON Syntax:

{
  "numNodes": integer,
  "mainNode": integer,
  "nodeRangeProperties": [
    {
      "targetNodes": "string",
      "container": {
        "image": "string",
        "vcpus": integer,
        "memory": integer,
        "command": ["string", ...],
        "jobRoleArn": "string",
        "volumes": [
          {
            "host": {
              "sourcePath": "string"
            },
            "name": "string"
          }
          ...
        ],
        "environment": [
          {
            "name": "string",
            "value": "string"
          }
          ...
        ],
        "mountPoints": [
          {
            "containerPath": "string",
            "readOnly": true|false,
            "sourceVolume": "string"
          }
          ...
        ],
        "readonlyRootFilesystem": true|false,
        "privileged": true|false,
        "ulimits": [
          {
            "hardLimit": integer,
            "name": "string",
            "softLimit": integer
          }
          ...
        ],
        "user": "string",
        "instanceType": "string",
        "resourceRequirements": [
          {
            "value": "string",
            "type": "GPU"
          }
          ...
        ],
        "linuxParameters": {
          "devices": [
            {
              "hostPath": "string",
              "containerPath": "string",
              "permissions": ["READ"|"WRITE"|"MKNOD", ...]
            }
            ...
          ]
        }
      }
    }
    ...
  ]
}

--retry-strategy (structure)

The retry strategy to use for failed jobs that are submitted with this job definition. Any retry strategy that is specified during a SubmitJob operation overrides the retry strategy defined here. If a job is terminated due to a timeout, it is not retried.

attempts -> (integer)

The number of times to move a job to the RUNNABLE status. You may specify between 1 and 10 attempts. If the value of attempts is greater than one, the job is retried on failure the same number of attempts as the value.

Shorthand Syntax:

attempts=integer

JSON Syntax:

{
  "attempts": integer
}

--timeout (structure)

The timeout configuration for jobs that are submitted with this job definition, after which AWS Batch terminates your jobs if they have not finished. If a job is terminated due to a timeout, it is not retried. The minimum value for the timeout is 60 seconds. Any timeout configuration that is specified during a SubmitJob operation overrides the timeout configuration defined here. For more information, see Job Timeouts in the Amazon Elastic Container Service Developer Guide .

attemptDurationSeconds -> (integer)

The time duration in seconds (measured from the job attempt’s startedAt timestamp) after which AWS Batch terminates your jobs if they have not finished.

Shorthand Syntax:

attemptDurationSeconds=integer

JSON Syntax:

{
  "attemptDurationSeconds": integer
}

--cli-input-json | --cli-input-yaml (string) Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. Similarly, if provided yaml-input it will print a sample input YAML that can be used with --cli-input-yaml. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

--cli-auto-prompt (boolean) Automatically prompt for CLI input parameters.

See ‘aws help’ for descriptions of global parameters.

Examples

To register a job definition

This example registers a job definition for a simple container job.

Command:

aws batch register-job-definition --job-definition-name sleep30 --type container --container-properties '{ "image": "busybox", "vcpus": 1, "memory": 128, "command": [ "sleep", "30"]}'

Output:

{
    "jobDefinitionArn": "arn:aws:batch:us-east-1:012345678910:job-definition/sleep30:1",
    "jobDefinitionName": "sleep30",
    "revision": 1
}

Output

jobDefinitionName -> (string)

The name of the job definition.

jobDefinitionArn -> (string)

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

revision -> (integer)

The revision of the job definition.