Class CfnTaskDefinition

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, ITaggable, 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.461Z") @Stability(Stable) public class CfnTaskDefinition extends CfnResource implements IInspectable, ITaggable
Registers a new task definition from the supplied family and containerDefinitions .

Optionally, you can add data volumes to your containers with the volumes parameter. For more information about task definition parameters and defaults, see Amazon ECS Task Definitions in the Amazon Elastic Container Service Developer Guide .

You can specify a role for your task with the taskRoleArn parameter. When you specify a role for a task, its containers can then use the latest versions of the AWS CLI or SDKs to make API requests to the AWS services that are specified in the policy that's associated with the role. For more information, see IAM Roles for Tasks in the Amazon Elastic Container Service Developer Guide .

You can specify a Docker networking mode for the containers in your task definition with the networkMode parameter. The available network modes correspond to those described in Network settings in the Docker run reference. If you specify the awsvpc network mode, the task is allocated an elastic network interface, and you must specify a NetworkConfiguration when you create a service or run a task with the task definition. For more information, see Task Networking in the Amazon Elastic Container Service Developer Guide .

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.services.ecs.*;
 CfnTaskDefinition cfnTaskDefinition = CfnTaskDefinition.Builder.create(this, "MyCfnTaskDefinition")
         .containerDefinitions(List.of(ContainerDefinitionProperty.builder()
                 .image("image")
                 .name("name")
                 // the properties below are optional
                 .command(List.of("command"))
                 .cpu(123)
                 .credentialSpecs(List.of("credentialSpecs"))
                 .dependsOn(List.of(ContainerDependencyProperty.builder()
                         .condition("condition")
                         .containerName("containerName")
                         .build()))
                 .disableNetworking(false)
                 .dnsSearchDomains(List.of("dnsSearchDomains"))
                 .dnsServers(List.of("dnsServers"))
                 .dockerLabels(Map.of(
                         "dockerLabelsKey", "dockerLabels"))
                 .dockerSecurityOptions(List.of("dockerSecurityOptions"))
                 .entryPoint(List.of("entryPoint"))
                 .environment(List.of(KeyValuePairProperty.builder()
                         .name("name")
                         .value("value")
                         .build()))
                 .environmentFiles(List.of(EnvironmentFileProperty.builder()
                         .type("type")
                         .value("value")
                         .build()))
                 .essential(false)
                 .extraHosts(List.of(HostEntryProperty.builder()
                         .hostname("hostname")
                         .ipAddress("ipAddress")
                         .build()))
                 .firelensConfiguration(FirelensConfigurationProperty.builder()
                         .options(Map.of(
                                 "optionsKey", "options"))
                         .type("type")
                         .build())
                 .healthCheck(HealthCheckProperty.builder()
                         .command(List.of("command"))
                         .interval(123)
                         .retries(123)
                         .startPeriod(123)
                         .timeout(123)
                         .build())
                 .hostname("hostname")
                 .interactive(false)
                 .links(List.of("links"))
                 .linuxParameters(LinuxParametersProperty.builder()
                         .capabilities(KernelCapabilitiesProperty.builder()
                                 .add(List.of("add"))
                                 .drop(List.of("drop"))
                                 .build())
                         .devices(List.of(DeviceProperty.builder()
                                 .containerPath("containerPath")
                                 .hostPath("hostPath")
                                 .permissions(List.of("permissions"))
                                 .build()))
                         .initProcessEnabled(false)
                         .maxSwap(123)
                         .sharedMemorySize(123)
                         .swappiness(123)
                         .tmpfs(List.of(TmpfsProperty.builder()
                                 .size(123)
                                 // the properties below are optional
                                 .containerPath("containerPath")
                                 .mountOptions(List.of("mountOptions"))
                                 .build()))
                         .build())
                 .logConfiguration(LogConfigurationProperty.builder()
                         .logDriver("logDriver")
                         // the properties below are optional
                         .options(Map.of(
                                 "optionsKey", "options"))
                         .secretOptions(List.of(SecretProperty.builder()
                                 .name("name")
                                 .valueFrom("valueFrom")
                                 .build()))
                         .build())
                 .memory(123)
                 .memoryReservation(123)
                 .mountPoints(List.of(MountPointProperty.builder()
                         .containerPath("containerPath")
                         .readOnly(false)
                         .sourceVolume("sourceVolume")
                         .build()))
                 .portMappings(List.of(PortMappingProperty.builder()
                         .appProtocol("appProtocol")
                         .containerPort(123)
                         .containerPortRange("containerPortRange")
                         .hostPort(123)
                         .name("name")
                         .protocol("protocol")
                         .build()))
                 .privileged(false)
                 .pseudoTerminal(false)
                 .readonlyRootFilesystem(false)
                 .repositoryCredentials(RepositoryCredentialsProperty.builder()
                         .credentialsParameter("credentialsParameter")
                         .build())
                 .resourceRequirements(List.of(ResourceRequirementProperty.builder()
                         .type("type")
                         .value("value")
                         .build()))
                 .secrets(List.of(SecretProperty.builder()
                         .name("name")
                         .valueFrom("valueFrom")
                         .build()))
                 .startTimeout(123)
                 .stopTimeout(123)
                 .systemControls(List.of(SystemControlProperty.builder()
                         .namespace("namespace")
                         .value("value")
                         .build()))
                 .ulimits(List.of(UlimitProperty.builder()
                         .hardLimit(123)
                         .name("name")
                         .softLimit(123)
                         .build()))
                 .user("user")
                 .volumesFrom(List.of(VolumeFromProperty.builder()
                         .readOnly(false)
                         .sourceContainer("sourceContainer")
                         .build()))
                 .workingDirectory("workingDirectory")
                 .build()))
         .cpu("cpu")
         .ephemeralStorage(EphemeralStorageProperty.builder()
                 .sizeInGiB(123)
                 .build())
         .executionRoleArn("executionRoleArn")
         .family("family")
         .inferenceAccelerators(List.of(InferenceAcceleratorProperty.builder()
                 .deviceName("deviceName")
                 .deviceType("deviceType")
                 .build()))
         .ipcMode("ipcMode")
         .memory("memory")
         .networkMode("networkMode")
         .pidMode("pidMode")
         .placementConstraints(List.of(TaskDefinitionPlacementConstraintProperty.builder()
                 .type("type")
                 // the properties below are optional
                 .expression("expression")
                 .build()))
         .proxyConfiguration(ProxyConfigurationProperty.builder()
                 .containerName("containerName")
                 // the properties below are optional
                 .proxyConfigurationProperties(List.of(KeyValuePairProperty.builder()
                         .name("name")
                         .value("value")
                         .build()))
                 .type("type")
                 .build())
         .requiresCompatibilities(List.of("requiresCompatibilities"))
         .runtimePlatform(RuntimePlatformProperty.builder()
                 .cpuArchitecture("cpuArchitecture")
                 .operatingSystemFamily("operatingSystemFamily")
                 .build())
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .taskRoleArn("taskRoleArn")
         .volumes(List.of(VolumeProperty.builder()
                 .configuredAtLaunch(false)
                 .dockerVolumeConfiguration(DockerVolumeConfigurationProperty.builder()
                         .autoprovision(false)
                         .driver("driver")
                         .driverOpts(Map.of(
                                 "driverOptsKey", "driverOpts"))
                         .labels(Map.of(
                                 "labelsKey", "labels"))
                         .scope("scope")
                         .build())
                 .efsVolumeConfiguration(EFSVolumeConfigurationProperty.builder()
                         .filesystemId("filesystemId")
                         // the properties below are optional
                         .authorizationConfig(AuthorizationConfigProperty.builder()
                                 .accessPointId("accessPointId")
                                 .iam("iam")
                                 .build())
                         .rootDirectory("rootDirectory")
                         .transitEncryption("transitEncryption")
                         .transitEncryptionPort(123)
                         .build())
                 .fSxWindowsFileServerVolumeConfiguration(FSxWindowsFileServerVolumeConfigurationProperty.builder()
                         .fileSystemId("fileSystemId")
                         .rootDirectory("rootDirectory")
                         // the properties below are optional
                         .authorizationConfig(FSxAuthorizationConfigProperty.builder()
                                 .credentialsParameter("credentialsParameter")
                                 .domain("domain")
                                 .build())
                         .build())
                 .host(HostVolumePropertiesProperty.builder()
                         .sourcePath("sourcePath")
                         .build())
                 .name("name")
                 .build()))
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnTaskDefinition

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

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

      @Stability(Stable) public CfnTaskDefinition(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable CfnTaskDefinitionProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties.
    • CfnTaskDefinition

      @Stability(Stable) public CfnTaskDefinition(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrTaskDefinitionArn

      @Stability(Stable) @NotNull public String getAttrTaskDefinitionArn()
      The ARN of the task definition.
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getTags in interface ITaggable
    • getContainerDefinitions

      @Stability(Stable) @Nullable public Object getContainerDefinitions()
      A list of container definitions in JSON format that describe the different containers that make up your task.
    • setContainerDefinitions

      @Stability(Stable) public void setContainerDefinitions(@Nullable IResolvable value)
      A list of container definitions in JSON format that describe the different containers that make up your task.
    • setContainerDefinitions

      @Stability(Stable) public void setContainerDefinitions(@Nullable List<Object> value)
      A list of container definitions in JSON format that describe the different containers that make up your task.
    • getCpu

      @Stability(Stable) @Nullable public String getCpu()
      The number of cpu units used by the task.
    • setCpu

      @Stability(Stable) public void setCpu(@Nullable String value)
      The number of cpu units used by the task.
    • getEphemeralStorage

      @Stability(Stable) @Nullable public Object getEphemeralStorage()
      The ephemeral storage settings to use for tasks run with the task definition.
    • setEphemeralStorage

      @Stability(Stable) public void setEphemeralStorage(@Nullable IResolvable value)
      The ephemeral storage settings to use for tasks run with the task definition.
    • setEphemeralStorage

      @Stability(Stable) public void setEphemeralStorage(@Nullable CfnTaskDefinition.EphemeralStorageProperty value)
      The ephemeral storage settings to use for tasks run with the task definition.
    • getExecutionRoleArn

      @Stability(Stable) @Nullable public String getExecutionRoleArn()
      The Amazon Resource Name (ARN) of the task execution role that grants the Amazon ECS container agent permission to make AWS API calls on your behalf.
    • setExecutionRoleArn

      @Stability(Stable) public void setExecutionRoleArn(@Nullable String value)
      The Amazon Resource Name (ARN) of the task execution role that grants the Amazon ECS container agent permission to make AWS API calls on your behalf.
    • getFamily

      @Stability(Stable) @Nullable public String getFamily()
      The name of a family that this task definition is registered to.
    • setFamily

      @Stability(Stable) public void setFamily(@Nullable String value)
      The name of a family that this task definition is registered to.
    • getInferenceAccelerators

      @Stability(Stable) @Nullable public Object getInferenceAccelerators()
      The Elastic Inference accelerators to use for the containers in the task.
    • setInferenceAccelerators

      @Stability(Stable) public void setInferenceAccelerators(@Nullable IResolvable value)
      The Elastic Inference accelerators to use for the containers in the task.
    • setInferenceAccelerators

      @Stability(Stable) public void setInferenceAccelerators(@Nullable List<Object> value)
      The Elastic Inference accelerators to use for the containers in the task.
    • getIpcMode

      @Stability(Stable) @Nullable public String getIpcMode()
      The IPC resource namespace to use for the containers in the task.
    • setIpcMode

      @Stability(Stable) public void setIpcMode(@Nullable String value)
      The IPC resource namespace to use for the containers in the task.
    • getMemory

      @Stability(Stable) @Nullable public String getMemory()
      The amount (in MiB) of memory used by the task.
    • setMemory

      @Stability(Stable) public void setMemory(@Nullable String value)
      The amount (in MiB) of memory used by the task.
    • getNetworkMode

      @Stability(Stable) @Nullable public String getNetworkMode()
      The Docker networking mode to use for the containers in the task.
    • setNetworkMode

      @Stability(Stable) public void setNetworkMode(@Nullable String value)
      The Docker networking mode to use for the containers in the task.
    • getPidMode

      @Stability(Stable) @Nullable public String getPidMode()
      The process namespace to use for the containers in the task.
    • setPidMode

      @Stability(Stable) public void setPidMode(@Nullable String value)
      The process namespace to use for the containers in the task.
    • getPlacementConstraints

      @Stability(Stable) @Nullable public Object getPlacementConstraints()
      An array of placement constraint objects to use for tasks.
    • setPlacementConstraints

      @Stability(Stable) public void setPlacementConstraints(@Nullable IResolvable value)
      An array of placement constraint objects to use for tasks.
    • setPlacementConstraints

      @Stability(Stable) public void setPlacementConstraints(@Nullable List<Object> value)
      An array of placement constraint objects to use for tasks.
    • getProxyConfiguration

      @Stability(Stable) @Nullable public Object getProxyConfiguration()
      The configuration details for the App Mesh proxy.
    • setProxyConfiguration

      @Stability(Stable) public void setProxyConfiguration(@Nullable IResolvable value)
      The configuration details for the App Mesh proxy.
    • setProxyConfiguration

      @Stability(Stable) public void setProxyConfiguration(@Nullable CfnTaskDefinition.ProxyConfigurationProperty value)
      The configuration details for the App Mesh proxy.
    • getRequiresCompatibilities

      @Stability(Stable) @Nullable public List<String> getRequiresCompatibilities()
      The task launch types the task definition was validated against.
    • setRequiresCompatibilities

      @Stability(Stable) public void setRequiresCompatibilities(@Nullable List<String> value)
      The task launch types the task definition was validated against.
    • getRuntimePlatform

      @Stability(Stable) @Nullable public Object getRuntimePlatform()
      The operating system that your tasks definitions run on.
    • setRuntimePlatform

      @Stability(Stable) public void setRuntimePlatform(@Nullable IResolvable value)
      The operating system that your tasks definitions run on.
    • setRuntimePlatform

      @Stability(Stable) public void setRuntimePlatform(@Nullable CfnTaskDefinition.RuntimePlatformProperty value)
      The operating system that your tasks definitions run on.
    • getTagsRaw

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      The metadata that you apply to the task definition to help you categorize and organize them.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      The metadata that you apply to the task definition to help you categorize and organize them.
    • getTaskRoleArn

      @Stability(Stable) @Nullable public String getTaskRoleArn()
      The short name or full Amazon Resource Name (ARN) of the AWS Identity and Access Management role that grants containers in the task permission to call AWS APIs on your behalf.
    • setTaskRoleArn

      @Stability(Stable) public void setTaskRoleArn(@Nullable String value)
      The short name or full Amazon Resource Name (ARN) of the AWS Identity and Access Management role that grants containers in the task permission to call AWS APIs on your behalf.
    • getVolumes

      @Stability(Stable) @Nullable public Object getVolumes()
      The list of data volume definitions for the task.
    • setVolumes

      @Stability(Stable) public void setVolumes(@Nullable IResolvable value)
      The list of data volume definitions for the task.
    • setVolumes

      @Stability(Stable) public void setVolumes(@Nullable List<Object> value)
      The list of data volume definitions for the task.