Class Ec2TaskDefinition

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.ecs.TaskDefinition
software.amazon.awscdk.services.ecs.Ec2TaskDefinition
All Implemented Interfaces:
IResource, IEc2TaskDefinition, ITaskDefinition, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-12-06T14:43:18.360Z") @Stability(Stable) public class Ec2TaskDefinition extends TaskDefinition implements IEc2TaskDefinition
The details of a task definition run on an EC2 cluster.

Example:

 Secret secret;
 // Create a Task Definition for the container to start
 Ec2TaskDefinition taskDefinition = new Ec2TaskDefinition(this, "TaskDef");
 taskDefinition.addContainer("TheContainer", ContainerDefinitionOptions.builder()
         .image(ContainerImage.fromRegistry("example-image"))
         .memoryLimitMiB(256)
         .logging(LogDrivers.splunk(SplunkLogDriverProps.builder()
                 .secretToken(secret)
                 .url("my-splunk-url")
                 .build()))
         .build());
 
  • Constructor Details

    • Ec2TaskDefinition

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

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

      @Stability(Stable) public Ec2TaskDefinition(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable Ec2TaskDefinitionProps props)
      Constructs a new instance of the Ec2TaskDefinition class.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props -
    • Ec2TaskDefinition

      @Stability(Stable) public Ec2TaskDefinition(@NotNull software.constructs.Construct scope, @NotNull String id)
      Constructs a new instance of the Ec2TaskDefinition class.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
  • Method Details

    • fromEc2TaskDefinitionArn

      @Stability(Stable) @NotNull public static IEc2TaskDefinition fromEc2TaskDefinitionArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String ec2TaskDefinitionArn)
      Imports a task definition from the specified task definition ARN.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      ec2TaskDefinitionArn - This parameter is required.
    • fromEc2TaskDefinitionAttributes

      @Stability(Stable) @NotNull public static IEc2TaskDefinition fromEc2TaskDefinitionAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull Ec2TaskDefinitionAttributes attrs)
      Imports an existing Ec2 task definition from its attributes.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • addContainer

      @Stability(Stable) @NotNull public ContainerDefinition addContainer(@NotNull String id, @NotNull ContainerDefinitionOptions props)
      Tasks running in AWSVPC networking mode requires an additional environment variable for the region to be sourced.

      This override adds in the additional environment variable as required

      Overrides:
      addContainer in class TaskDefinition
      Parameters:
      id - This parameter is required.
      props - This parameter is required.