JobDefinition

class aws_cdk.aws_batch.JobDefinition(scope, id, *, container, job_definition_name=None, node_props=None, parameters=None, platform_capabilities=None, retry_attempts=None, timeout=None)

Bases: Resource

(experimental) Batch Job Definition.

Defines a batch job definition to execute a specific batch job.

Stability:

experimental

ExampleMetadata:

infused

Example:

import aws_cdk.aws_ecr as ecr


repo = ecr.Repository.from_repository_name(self, "batch-job-repo", "todo-list")

batch.JobDefinition(self, "batch-job-def-from-ecr",
    container=batch.JobDefinitionContainer(
        image=ecs.EcrImage(repo, "latest")
    )
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • container (Union[JobDefinitionContainer, Dict[str, Any]]) – (experimental) An object with various properties specific to container-based jobs.

  • job_definition_name (Optional[str]) – (experimental) The name of the job definition. Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed. Default: Cloudformation-generated name

  • node_props (Optional[IMultiNodeProps]) – (experimental) An object with various properties specific to multi-node parallel jobs. Default: - undefined

  • parameters (Optional[Mapping[str, str]]) – (experimental) When you submit a job, you can specify parameters that should replace the placeholders or override the default job definition parameters. Parameters in job submission requests take precedence over the defaults in a job definition. This allows you to use the same job definition for multiple jobs that use the same format, and programmatically change values in the command at submission time. Default: - undefined

  • platform_capabilities (Optional[Sequence[PlatformCapabilities]]) – (experimental) The platform capabilities required by the job definition. Default: - EC2

  • retry_attempts (Union[int, float, None]) – (experimental) 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. Default: 1

  • timeout (Optional[Duration]) – (experimental) The timeout configuration for jobs that are submitted with this job definition. You can specify a timeout duration after which AWS Batch terminates your jobs if they have not finished. Default: - undefined

Stability:

experimental

Methods

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

job_definition_arn

(experimental) The ARN of this batch job definition.

Stability:

experimental

job_definition_name

(experimental) The name of the batch job definition.

Stability:

experimental

node

The construct tree node associated with this construct.

stack

The stack in which this resource is defined.

Static Methods

classmethod from_job_definition_arn(scope, id, job_definition_arn)

(experimental) Imports an existing batch job definition by its amazon resource name.

Parameters:
  • scope (Construct) –

  • id (str) –

  • job_definition_arn (str) –

Stability:

experimental

Return type:

IJobDefinition

classmethod from_job_definition_name(scope, id, job_definition_name)

(experimental) Imports an existing batch job definition by its name.

If name is specified without a revision then the latest active revision is used.

Parameters:
  • scope (Construct) –

  • id (str) –

  • job_definition_name (str) –

Stability:

experimental

Return type:

IJobDefinition

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool