Skip to content

BatchDefinition

Bases: DuploResourceV3

Manage AWS Batch Job Definition Resources

Manage batch Job Definitions as a resource in Duplo.

Read more docs here: https://docs.duplocloud.com/docs/overview/aws-services/batch

Commands

apply

Apply a BatchDefinition

Create or Update a BatchDefinition resource with Duplocloud cli.

CLI Usage

duploctl batchdefinition apply -f 'batchdefinition.yaml'
Contents of the batchdefinition.yaml file
JobDefinitionName: duploctl
ContainerProperties:
  Command:
  - sleep
  - '10'
  Image: alpine:latest
  ResourceRequirements:
  - Type: MEMORY
    Value: '2048'
  - Type: VCPU
    Value: '2'
PlatformCapabilities:
- EC2

Returns:

Name Type Description
message dict

Success message.

Parameters:

--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
str action: JsonPatchAction

create

Create a Batch Job Definition resource.

CLI Usage

duploctl batch_definition create -f 'batchdefinition.yaml'
Contents of the batchdefinition.yaml file
JobDefinitionName: duploctl
ContainerProperties:
  Command:
  - sleep
  - '10'
  Image: alpine:latest
  ResourceRequirements:
  - Type: MEMORY
    Value: '2048'
  - Type: VCPU
    Value: '2'
PlatformCapabilities:
- EC2

One liner example
echo """
JobDefinitionName: duploctl
ContainerProperties:
  Command:
  - sleep
  - '10'
  Image: alpine:latest
  ResourceRequirements:
  - Type: MEMORY
    Value: '2048'
  - Type: VCPU
    Value: '2'
PlatformCapabilities:
- EC2
""" | duploctl batch_definition create -f -

Returns:

Name Type Description
message dict

Success message.

Raises:

Type Description
DuploError

If the resource could not be created.

Parameters:

--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction

delete

Delete a Batch Job Definition by name.

CLI Usage
duploctl batch_definition delete <name>

Returns:

Name Type Description
message dict

Success message.

Parameters:

name positional
The resource name
str
--revision, --to-revision
The revision to rollback to
int
--all, --all
Boolean flag to select all. Defaults to False.

find

Find a Single Batch Job Definition by name.

cli usage
duploctl batch_definition find <name>
Example

Find the previous revision to the latest. This is what you would use to do a rollback.

duploctl batch_definition find myjobdef --revision -2

Example

Find the earliest revision of a job definition.

duploctl batch_definition find myjobdef --revision 0

Returns:

Name Type Description
resource dict

The Batch Job Definition object.

Parameters:

name positional
The resource name
str
--revision, --to-revision
The revision to rollback to
int

list

List all Batch Job Definitions.

Usage
duploctl batch_definition list
Example

Retrieve all of the revision IDs for one job definition using JMESPATH query and output as yaml

duploctl batch_definition list --query "[?JobDefinitionName=='duploservices-dev01-myjobdef'].Revision" -o yaml

Returns:

Name Type Description
list list

A list of Batch Job Definitions.

update

Update a V3 resource by name.

Returns:

Name Type Description
message

Success message.

Raises:

Type Description
DuploError

If the resource could not be created.

Parameters:

name positional
The resource name
str
--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
str action: JsonPatchAction

update_image

Update the image of a Batch Job Definition by name.

CLI Usage
duploctl batch_definition update_image <name> <image>

Returns:

Name Type Description
message dict

Success message.

Parameters:

name positional
The resource name
str
image positional
The image to use
str

Methods

name_from_body