Batch / Client / register_job_definition

register_job_definition#

Batch.Client.register_job_definition(**kwargs)#

Registers an Batch job definition.

See also: AWS API Documentation

Request Syntax

response = client.register_job_definition(
    jobDefinitionName='string',
    type='container'|'multinode',
    parameters={
        'string': 'string'
    },
    schedulingPriority=123,
    containerProperties={
        'image': 'string',
        'vcpus': 123,
        'memory': 123,
        'command': [
            'string',
        ],
        'jobRoleArn': 'string',
        'executionRoleArn': 'string',
        'volumes': [
            {
                'host': {
                    'sourcePath': 'string'
                },
                'name': 'string',
                'efsVolumeConfiguration': {
                    'fileSystemId': 'string',
                    'rootDirectory': 'string',
                    'transitEncryption': 'ENABLED'|'DISABLED',
                    'transitEncryptionPort': 123,
                    'authorizationConfig': {
                        'accessPointId': 'string',
                        'iam': 'ENABLED'|'DISABLED'
                    }
                }
            },
        ],
        'environment': [
            {
                'name': 'string',
                'value': 'string'
            },
        ],
        'mountPoints': [
            {
                'containerPath': 'string',
                'readOnly': True|False,
                'sourceVolume': 'string'
            },
        ],
        'readonlyRootFilesystem': True|False,
        'privileged': True|False,
        'ulimits': [
            {
                'hardLimit': 123,
                'name': 'string',
                'softLimit': 123
            },
        ],
        'user': 'string',
        'instanceType': 'string',
        'resourceRequirements': [
            {
                'value': 'string',
                'type': 'GPU'|'VCPU'|'MEMORY'
            },
        ],
        'linuxParameters': {
            'devices': [
                {
                    'hostPath': 'string',
                    'containerPath': 'string',
                    'permissions': [
                        'READ'|'WRITE'|'MKNOD',
                    ]
                },
            ],
            'initProcessEnabled': True|False,
            'sharedMemorySize': 123,
            'tmpfs': [
                {
                    'containerPath': 'string',
                    'size': 123,
                    'mountOptions': [
                        'string',
                    ]
                },
            ],
            'maxSwap': 123,
            'swappiness': 123
        },
        'logConfiguration': {
            'logDriver': 'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk',
            'options': {
                'string': 'string'
            },
            'secretOptions': [
                {
                    'name': 'string',
                    'valueFrom': 'string'
                },
            ]
        },
        'secrets': [
            {
                'name': 'string',
                'valueFrom': 'string'
            },
        ],
        'networkConfiguration': {
            'assignPublicIp': 'ENABLED'|'DISABLED'
        },
        'fargatePlatformConfiguration': {
            'platformVersion': 'string'
        },
        'ephemeralStorage': {
            'sizeInGiB': 123
        },
        'runtimePlatform': {
            'operatingSystemFamily': 'string',
            'cpuArchitecture': 'string'
        },
        'repositoryCredentials': {
            'credentialsParameter': 'string'
        }
    },
    nodeProperties={
        'numNodes': 123,
        'mainNode': 123,
        'nodeRangeProperties': [
            {
                'targetNodes': 'string',
                'container': {
                    'image': 'string',
                    'vcpus': 123,
                    'memory': 123,
                    'command': [
                        'string',
                    ],
                    'jobRoleArn': 'string',
                    'executionRoleArn': 'string',
                    'volumes': [
                        {
                            'host': {
                                'sourcePath': 'string'
                            },
                            'name': 'string',
                            'efsVolumeConfiguration': {
                                'fileSystemId': 'string',
                                'rootDirectory': 'string',
                                'transitEncryption': 'ENABLED'|'DISABLED',
                                'transitEncryptionPort': 123,
                                'authorizationConfig': {
                                    'accessPointId': 'string',
                                    'iam': 'ENABLED'|'DISABLED'
                                }
                            }
                        },
                    ],
                    'environment': [
                        {
                            'name': 'string',
                            'value': 'string'
                        },
                    ],
                    'mountPoints': [
                        {
                            'containerPath': 'string',
                            'readOnly': True|False,
                            'sourceVolume': 'string'
                        },
                    ],
                    'readonlyRootFilesystem': True|False,
                    'privileged': True|False,
                    'ulimits': [
                        {
                            'hardLimit': 123,
                            'name': 'string',
                            'softLimit': 123
                        },
                    ],
                    'user': 'string',
                    'instanceType': 'string',
                    'resourceRequirements': [
                        {
                            'value': 'string',
                            'type': 'GPU'|'VCPU'|'MEMORY'
                        },
                    ],
                    'linuxParameters': {
                        'devices': [
                            {
                                'hostPath': 'string',
                                'containerPath': 'string',
                                'permissions': [
                                    'READ'|'WRITE'|'MKNOD',
                                ]
                            },
                        ],
                        'initProcessEnabled': True|False,
                        'sharedMemorySize': 123,
                        'tmpfs': [
                            {
                                'containerPath': 'string',
                                'size': 123,
                                'mountOptions': [
                                    'string',
                                ]
                            },
                        ],
                        'maxSwap': 123,
                        'swappiness': 123
                    },
                    'logConfiguration': {
                        'logDriver': 'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk',
                        'options': {
                            'string': 'string'
                        },
                        'secretOptions': [
                            {
                                'name': 'string',
                                'valueFrom': 'string'
                            },
                        ]
                    },
                    'secrets': [
                        {
                            'name': 'string',
                            'valueFrom': 'string'
                        },
                    ],
                    'networkConfiguration': {
                        'assignPublicIp': 'ENABLED'|'DISABLED'
                    },
                    'fargatePlatformConfiguration': {
                        'platformVersion': 'string'
                    },
                    'ephemeralStorage': {
                        'sizeInGiB': 123
                    },
                    'runtimePlatform': {
                        'operatingSystemFamily': 'string',
                        'cpuArchitecture': 'string'
                    },
                    'repositoryCredentials': {
                        'credentialsParameter': 'string'
                    }
                },
                'instanceTypes': [
                    'string',
                ],
                'ecsProperties': {
                    'taskProperties': [
                        {
                            'containers': [
                                {
                                    'command': [
                                        'string',
                                    ],
                                    'dependsOn': [
                                        {
                                            'containerName': 'string',
                                            'condition': 'string'
                                        },
                                    ],
                                    'environment': [
                                        {
                                            'name': 'string',
                                            'value': 'string'
                                        },
                                    ],
                                    'essential': True|False,
                                    'image': 'string',
                                    'linuxParameters': {
                                        'devices': [
                                            {
                                                'hostPath': 'string',
                                                'containerPath': 'string',
                                                'permissions': [
                                                    'READ'|'WRITE'|'MKNOD',
                                                ]
                                            },
                                        ],
                                        'initProcessEnabled': True|False,
                                        'sharedMemorySize': 123,
                                        'tmpfs': [
                                            {
                                                'containerPath': 'string',
                                                'size': 123,
                                                'mountOptions': [
                                                    'string',
                                                ]
                                            },
                                        ],
                                        'maxSwap': 123,
                                        'swappiness': 123
                                    },
                                    'logConfiguration': {
                                        'logDriver': 'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk',
                                        'options': {
                                            'string': 'string'
                                        },
                                        'secretOptions': [
                                            {
                                                'name': 'string',
                                                'valueFrom': 'string'
                                            },
                                        ]
                                    },
                                    'mountPoints': [
                                        {
                                            'containerPath': 'string',
                                            'readOnly': True|False,
                                            'sourceVolume': 'string'
                                        },
                                    ],
                                    'name': 'string',
                                    'privileged': True|False,
                                    'readonlyRootFilesystem': True|False,
                                    'repositoryCredentials': {
                                        'credentialsParameter': 'string'
                                    },
                                    'resourceRequirements': [
                                        {
                                            'value': 'string',
                                            'type': 'GPU'|'VCPU'|'MEMORY'
                                        },
                                    ],
                                    'secrets': [
                                        {
                                            'name': 'string',
                                            'valueFrom': 'string'
                                        },
                                    ],
                                    'ulimits': [
                                        {
                                            'hardLimit': 123,
                                            'name': 'string',
                                            'softLimit': 123
                                        },
                                    ],
                                    'user': 'string'
                                },
                            ],
                            'ephemeralStorage': {
                                'sizeInGiB': 123
                            },
                            'executionRoleArn': 'string',
                            'platformVersion': 'string',
                            'ipcMode': 'string',
                            'taskRoleArn': 'string',
                            'pidMode': 'string',
                            'networkConfiguration': {
                                'assignPublicIp': 'ENABLED'|'DISABLED'
                            },
                            'runtimePlatform': {
                                'operatingSystemFamily': 'string',
                                'cpuArchitecture': 'string'
                            },
                            'volumes': [
                                {
                                    'host': {
                                        'sourcePath': 'string'
                                    },
                                    'name': 'string',
                                    'efsVolumeConfiguration': {
                                        'fileSystemId': 'string',
                                        'rootDirectory': 'string',
                                        'transitEncryption': 'ENABLED'|'DISABLED',
                                        'transitEncryptionPort': 123,
                                        'authorizationConfig': {
                                            'accessPointId': 'string',
                                            'iam': 'ENABLED'|'DISABLED'
                                        }
                                    }
                                },
                            ]
                        },
                    ]
                },
                'eksProperties': {
                    'podProperties': {
                        'serviceAccountName': 'string',
                        'hostNetwork': True|False,
                        'dnsPolicy': 'string',
                        'imagePullSecrets': [
                            {
                                'name': 'string'
                            },
                        ],
                        'containers': [
                            {
                                'name': 'string',
                                'image': 'string',
                                'imagePullPolicy': 'string',
                                'command': [
                                    'string',
                                ],
                                'args': [
                                    'string',
                                ],
                                'env': [
                                    {
                                        'name': 'string',
                                        'value': 'string'
                                    },
                                ],
                                'resources': {
                                    'limits': {
                                        'string': 'string'
                                    },
                                    'requests': {
                                        'string': 'string'
                                    }
                                },
                                'volumeMounts': [
                                    {
                                        'name': 'string',
                                        'mountPath': 'string',
                                        'readOnly': True|False
                                    },
                                ],
                                'securityContext': {
                                    'runAsUser': 123,
                                    'runAsGroup': 123,
                                    'privileged': True|False,
                                    'allowPrivilegeEscalation': True|False,
                                    'readOnlyRootFilesystem': True|False,
                                    'runAsNonRoot': True|False
                                }
                            },
                        ],
                        'initContainers': [
                            {
                                'name': 'string',
                                'image': 'string',
                                'imagePullPolicy': 'string',
                                'command': [
                                    'string',
                                ],
                                'args': [
                                    'string',
                                ],
                                'env': [
                                    {
                                        'name': 'string',
                                        'value': 'string'
                                    },
                                ],
                                'resources': {
                                    'limits': {
                                        'string': 'string'
                                    },
                                    'requests': {
                                        'string': 'string'
                                    }
                                },
                                'volumeMounts': [
                                    {
                                        'name': 'string',
                                        'mountPath': 'string',
                                        'readOnly': True|False
                                    },
                                ],
                                'securityContext': {
                                    'runAsUser': 123,
                                    'runAsGroup': 123,
                                    'privileged': True|False,
                                    'allowPrivilegeEscalation': True|False,
                                    'readOnlyRootFilesystem': True|False,
                                    'runAsNonRoot': True|False
                                }
                            },
                        ],
                        'volumes': [
                            {
                                'name': 'string',
                                'hostPath': {
                                    'path': 'string'
                                },
                                'emptyDir': {
                                    'medium': 'string',
                                    'sizeLimit': 'string'
                                },
                                'secret': {
                                    'secretName': 'string',
                                    'optional': True|False
                                }
                            },
                        ],
                        'metadata': {
                            'labels': {
                                'string': 'string'
                            }
                        },
                        'shareProcessNamespace': True|False
                    }
                }
            },
        ]
    },
    retryStrategy={
        'attempts': 123,
        'evaluateOnExit': [
            {
                'onStatusReason': 'string',
                'onReason': 'string',
                'onExitCode': 'string',
                'action': 'RETRY'|'EXIT'
            },
        ]
    },
    propagateTags=True|False,
    timeout={
        'attemptDurationSeconds': 123
    },
    tags={
        'string': 'string'
    },
    platformCapabilities=[
        'EC2'|'FARGATE',
    ],
    eksProperties={
        'podProperties': {
            'serviceAccountName': 'string',
            'hostNetwork': True|False,
            'dnsPolicy': 'string',
            'imagePullSecrets': [
                {
                    'name': 'string'
                },
            ],
            'containers': [
                {
                    'name': 'string',
                    'image': 'string',
                    'imagePullPolicy': 'string',
                    'command': [
                        'string',
                    ],
                    'args': [
                        'string',
                    ],
                    'env': [
                        {
                            'name': 'string',
                            'value': 'string'
                        },
                    ],
                    'resources': {
                        'limits': {
                            'string': 'string'
                        },
                        'requests': {
                            'string': 'string'
                        }
                    },
                    'volumeMounts': [
                        {
                            'name': 'string',
                            'mountPath': 'string',
                            'readOnly': True|False
                        },
                    ],
                    'securityContext': {
                        'runAsUser': 123,
                        'runAsGroup': 123,
                        'privileged': True|False,
                        'allowPrivilegeEscalation': True|False,
                        'readOnlyRootFilesystem': True|False,
                        'runAsNonRoot': True|False
                    }
                },
            ],
            'initContainers': [
                {
                    'name': 'string',
                    'image': 'string',
                    'imagePullPolicy': 'string',
                    'command': [
                        'string',
                    ],
                    'args': [
                        'string',
                    ],
                    'env': [
                        {
                            'name': 'string',
                            'value': 'string'
                        },
                    ],
                    'resources': {
                        'limits': {
                            'string': 'string'
                        },
                        'requests': {
                            'string': 'string'
                        }
                    },
                    'volumeMounts': [
                        {
                            'name': 'string',
                            'mountPath': 'string',
                            'readOnly': True|False
                        },
                    ],
                    'securityContext': {
                        'runAsUser': 123,
                        'runAsGroup': 123,
                        'privileged': True|False,
                        'allowPrivilegeEscalation': True|False,
                        'readOnlyRootFilesystem': True|False,
                        'runAsNonRoot': True|False
                    }
                },
            ],
            'volumes': [
                {
                    'name': 'string',
                    'hostPath': {
                        'path': 'string'
                    },
                    'emptyDir': {
                        'medium': 'string',
                        'sizeLimit': 'string'
                    },
                    'secret': {
                        'secretName': 'string',
                        'optional': True|False
                    }
                },
            ],
            'metadata': {
                'labels': {
                    'string': 'string'
                }
            },
            'shareProcessNamespace': True|False
        }
    },
    ecsProperties={
        'taskProperties': [
            {
                'containers': [
                    {
                        'command': [
                            'string',
                        ],
                        'dependsOn': [
                            {
                                'containerName': 'string',
                                'condition': 'string'
                            },
                        ],
                        'environment': [
                            {
                                'name': 'string',
                                'value': 'string'
                            },
                        ],
                        'essential': True|False,
                        'image': 'string',
                        'linuxParameters': {
                            'devices': [
                                {
                                    'hostPath': 'string',
                                    'containerPath': 'string',
                                    'permissions': [
                                        'READ'|'WRITE'|'MKNOD',
                                    ]
                                },
                            ],
                            'initProcessEnabled': True|False,
                            'sharedMemorySize': 123,
                            'tmpfs': [
                                {
                                    'containerPath': 'string',
                                    'size': 123,
                                    'mountOptions': [
                                        'string',
                                    ]
                                },
                            ],
                            'maxSwap': 123,
                            'swappiness': 123
                        },
                        'logConfiguration': {
                            'logDriver': 'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk',
                            'options': {
                                'string': 'string'
                            },
                            'secretOptions': [
                                {
                                    'name': 'string',
                                    'valueFrom': 'string'
                                },
                            ]
                        },
                        'mountPoints': [
                            {
                                'containerPath': 'string',
                                'readOnly': True|False,
                                'sourceVolume': 'string'
                            },
                        ],
                        'name': 'string',
                        'privileged': True|False,
                        'readonlyRootFilesystem': True|False,
                        'repositoryCredentials': {
                            'credentialsParameter': 'string'
                        },
                        'resourceRequirements': [
                            {
                                'value': 'string',
                                'type': 'GPU'|'VCPU'|'MEMORY'
                            },
                        ],
                        'secrets': [
                            {
                                'name': 'string',
                                'valueFrom': 'string'
                            },
                        ],
                        'ulimits': [
                            {
                                'hardLimit': 123,
                                'name': 'string',
                                'softLimit': 123
                            },
                        ],
                        'user': 'string'
                    },
                ],
                'ephemeralStorage': {
                    'sizeInGiB': 123
                },
                'executionRoleArn': 'string',
                'platformVersion': 'string',
                'ipcMode': 'string',
                'taskRoleArn': 'string',
                'pidMode': 'string',
                'networkConfiguration': {
                    'assignPublicIp': 'ENABLED'|'DISABLED'
                },
                'runtimePlatform': {
                    'operatingSystemFamily': 'string',
                    'cpuArchitecture': 'string'
                },
                'volumes': [
                    {
                        'host': {
                            'sourcePath': 'string'
                        },
                        'name': 'string',
                        'efsVolumeConfiguration': {
                            'fileSystemId': 'string',
                            'rootDirectory': 'string',
                            'transitEncryption': 'ENABLED'|'DISABLED',
                            'transitEncryptionPort': 123,
                            'authorizationConfig': {
                                'accessPointId': 'string',
                                'iam': 'ENABLED'|'DISABLED'
                            }
                        }
                    },
                ]
            },
        ]
    }
)


**Parameters**
::

    # This section is too large to render.
    # Please see the AWS API Documentation linked below.

`AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/batch-2016-08-10/RegisterJobDefinition>`_
Return type:

dict

Returns:

Response Syntax

{
    'jobDefinitionName': 'string',
    'jobDefinitionArn': 'string',
    'revision': 123
}

Response Structure

  • (dict) –

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

Exceptions

Examples

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

response = client.register_job_definition(
    type='container',
    containerProperties={
        'command': [
            'sleep',
            '10',
        ],
        'image': 'busybox',
        'resourceRequirements': [
            {
                'type': 'MEMORY',
                'value': '128',
            },
            {
                'type': 'VCPU',
                'value': '1',
            },
        ],
    },
    jobDefinitionName='sleep10',
)

print(response)

Expected Output:

{
    'jobDefinitionArn': 'arn:aws:batch:us-east-1:012345678910:job-definition/sleep10:1',
    'jobDefinitionName': 'sleep10',
    'revision': 1,
    'ResponseMetadata': {
        '...': '...',
    },
}

This demonstrates calling the RegisterJobDefinition action, including tags.

response = client.register_job_definition(
    type='container',
    containerProperties={
        'command': [
            'sleep',
            '30',
        ],
        'image': 'busybox',
        'resourceRequirements': [
            {
                'type': 'MEMORY',
                'value': '128',
            },
            {
                'type': 'VCPU',
                'value': '1',
            },
        ],
    },
    jobDefinitionName='sleep30',
    tags={
        'Department': 'Engineering',
        'User': 'JaneDoe',
    },
)

print(response)

Expected Output:

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