RetryStrategy

class aws_cdk.aws_batch.RetryStrategy(action, on)

Bases: object

Define how Jobs using this JobDefinition respond to different exit conditions.

ExampleMetadata:

infused

Example:

job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256
    ),
    retry_attempts=5,
    retry_strategies=[
        batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.CANNOT_PULL_CONTAINER)
    ]
)
job_defn.add_retry_strategy(
    batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.SPOT_INSTANCE_RECLAIMED))
job_defn.add_retry_strategy(
    batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.CANNOT_PULL_CONTAINER))
job_defn.add_retry_strategy(
    batch.RetryStrategy.of(batch.Action.EXIT, batch.Reason.custom(
        on_exit_code="40*",
        on_reason="some reason"
    )))
Parameters:

Attributes

action

The action to take when the job exits with the Reason specified.

on

If the job exits with this Reason it will trigger the specified Action.

Static Methods

classmethod of(action, on)

Create a new RetryStrategy.

Parameters:
Return type:

RetryStrategy