Class FargateTaskDefinition

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.FargateTaskDefinition
All Implemented Interfaces:
IResource, IFargateTaskDefinition, ITaskDefinition, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-08T21:35:06.569Z") @Stability(Stable) public class FargateTaskDefinition extends TaskDefinition implements IFargateTaskDefinition
The details of a task definition run on a Fargate cluster.

Example:

 Vpc vpc;
 Cluster cluster = Cluster.Builder.create(this, "FargateCPCluster")
         .vpc(vpc)
         .enableFargateCapacityProviders(true)
         .build();
 FargateTaskDefinition taskDefinition = new FargateTaskDefinition(this, "TaskDef");
 taskDefinition.addContainer("web", ContainerDefinitionOptions.builder()
         .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
         .build());
 FargateService.Builder.create(this, "FargateService")
         .cluster(cluster)
         .taskDefinition(taskDefinition)
         .capacityProviderStrategies(List.of(CapacityProviderStrategy.builder()
                 .capacityProvider("FARGATE_SPOT")
                 .weight(2)
                 .build(), CapacityProviderStrategy.builder()
                 .capacityProvider("FARGATE")
                 .weight(1)
                 .build()))
         .build();
 
  • Constructor Details

    • FargateTaskDefinition

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

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

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

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

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

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

    • fromFargateTaskDefinitionArn

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

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      fargateTaskDefinitionArn - This parameter is required.
    • fromFargateTaskDefinitionAttributes

      @Stability(Stable) @NotNull public static IFargateTaskDefinition fromFargateTaskDefinitionAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull FargateTaskDefinitionAttributes attrs)
      Import an existing Fargate task definition from its attributes.

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

      @Stability(Stable) @NotNull public NetworkMode getNetworkMode()
      The Docker networking mode to use for the containers in the task.

      Fargate tasks require the awsvpc network mode.

      Specified by:
      getNetworkMode in interface ITaskDefinition
      Overrides:
      getNetworkMode in class TaskDefinition
    • getEphemeralStorageGiB

      @Stability(Stable) @Nullable public Number getEphemeralStorageGiB()
      The amount (in GiB) of ephemeral storage to be allocated to the task.
      Overrides:
      getEphemeralStorageGiB in class TaskDefinition