Class EcsJobDefinition

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.batch.EcsJobDefinition
All Implemented Interfaces:
IResource, IJobDefinition, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-25T14:21:10.932Z") @Stability(Stable) public class EcsJobDefinition extends Resource implements IJobDefinition
A JobDefinition that uses ECS orchestration.

Example:

 IVpc vpc;
 EcsJobDefinition ecsJob = EcsJobDefinition.Builder.create(this, "JobDefn")
         .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                 .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                 .memory(Size.mebibytes(2048))
                 .cpu(256)
                 .build())
         .build();
 JobQueue queue = JobQueue.Builder.create(this, "JobQueue")
         .computeEnvironments(List.of(OrderedComputeEnvironment.builder()
                 .computeEnvironment(ManagedEc2EcsComputeEnvironment.Builder.create(this, "managedEc2CE")
                         .vpc(vpc)
                         .build())
                 .order(1)
                 .build()))
         .priority(10)
         .build();
 User user = new User(this, "MyUser");
 ecsJob.grantSubmitJob(user, queue);
 
  • Constructor Details

    • EcsJobDefinition

      protected EcsJobDefinition(software.amazon.jsii.JsiiObjectRef objRef)
    • EcsJobDefinition

      protected EcsJobDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • EcsJobDefinition

      @Stability(Stable) public EcsJobDefinition(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull EcsJobDefinitionProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromJobDefinitionArn

      @Stability(Stable) @NotNull public static IJobDefinition fromJobDefinitionArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String jobDefinitionArn)
      Import a JobDefinition by its arn.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      jobDefinitionArn - This parameter is required.
    • addRetryStrategy

      @Stability(Stable) public void addRetryStrategy(@NotNull RetryStrategy strategy)
      Add a RetryStrategy to this JobDefinition.

      Specified by:
      addRetryStrategy in interface IJobDefinition
      Parameters:
      strategy - This parameter is required.
    • grantSubmitJob

      @Stability(Stable) public void grantSubmitJob(@NotNull IGrantable identity, @NotNull IJobQueue queue)
      Grants the batch:submitJob permission to the identity on both this job definition and the queue.

      Parameters:
      identity - This parameter is required.
      queue - This parameter is required.
    • getContainer

      @Stability(Stable) @NotNull public IEcsContainerDefinition getContainer()
      The container that this job will run.
    • getJobDefinitionArn

      @Stability(Stable) @NotNull public String getJobDefinitionArn()
      The ARN of this job definition.
      Specified by:
      getJobDefinitionArn in interface IJobDefinition
    • getJobDefinitionName

      @Stability(Stable) @NotNull public String getJobDefinitionName()
      The name of this job definition.
      Specified by:
      getJobDefinitionName in interface IJobDefinition
    • getRetryStrategies

      @Stability(Stable) @NotNull public List<RetryStrategy> getRetryStrategies()
      Defines the retry behavior for this job.
      Specified by:
      getRetryStrategies in interface IJobDefinition
    • getParameters

      @Stability(Stable) @Nullable public Map<String,Object> getParameters()
      The default parameters passed to the container These parameters can be referenced in the command that you give to the container.
      Specified by:
      getParameters in interface IJobDefinition
      See Also:
    • getPropagateTags

      @Stability(Stable) @Nullable public Boolean getPropagateTags()
      Whether to propogate tags from the JobDefinition to the ECS task that Batch spawns.
    • getRetryAttempts

      @Stability(Stable) @Nullable public Number getRetryAttempts()
      The number of times to retry a job.

      The job is retried on failure the same number of attempts as the value.

      Specified by:
      getRetryAttempts in interface IJobDefinition
    • getSchedulingPriority

      @Stability(Stable) @Nullable public Number getSchedulingPriority()
      The priority of this Job.

      Only used in Fairshare Scheduling to decide which job to run first when there are multiple jobs with the same share identifier.

      Specified by:
      getSchedulingPriority in interface IJobDefinition
    • getTimeout

      @Stability(Stable) @Nullable public Duration getTimeout()
      The timeout time for jobs that are submitted with this job definition.

      After the amount of time you specify passes, Batch terminates your jobs if they aren't finished.

      Specified by:
      getTimeout in interface IJobDefinition