Class TaskDefinition
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.ecs.TaskDefinition
- All Implemented Interfaces:
IConstruct
,IDependable
,IResource
,ITaskDefinition
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
- Direct Known Subclasses:
Ec2TaskDefinition
,ExternalTaskDefinition
,FargateTaskDefinition
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:47.479Z")
@Stability(Stable)
public class TaskDefinition
extends Resource
implements ITaskDefinition
The base class for all task definitions.
Example:
Cluster cluster; TaskDefinition taskDefinition; Vpc vpc; FargateService service = FargateService.Builder.create(this, "Service").cluster(cluster).taskDefinition(taskDefinition).build(); ApplicationLoadBalancer lb = ApplicationLoadBalancer.Builder.create(this, "LB").vpc(vpc).internetFacing(true).build(); ApplicationListener listener = lb.addListener("Listener", BaseApplicationListenerProps.builder().port(80).build()); service.registerLoadBalancerTargets(EcsTarget.builder() .containerName("web") .containerPort(80) .newTargetGroupId("ECS") .listener(ListenerConfig.applicationListener(listener, AddApplicationTargetsProps.builder() .protocol(ApplicationProtocol.HTTPS) .build())) .build());
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.ecs.ITaskDefinition
ITaskDefinition.Jsii$Default, ITaskDefinition.Jsii$Proxy
-
Constructor Summary
ModifierConstructorDescriptionprotected
TaskDefinition
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
TaskDefinition
(software.amazon.jsii.JsiiObjectRef objRef) TaskDefinition
(software.constructs.Construct scope, String id, TaskDefinitionProps props) Constructs a new instance of the TaskDefinition class. -
Method Summary
Modifier and TypeMethodDescriptionaddContainer
(String id, ContainerDefinitionOptions props) Adds a new container to the task definition.void
addExtension
(ITaskDefinitionExtension extension) Adds the specified extension to the task definition.Adds a firelens log router to the task definition.void
addInferenceAccelerator
(InferenceAccelerator inferenceAccelerator) Adds an inference accelerator to the task definition.void
addPlacementConstraint
(PlacementConstraint constraint) Adds the specified placement constraint to the task definition.void
addToExecutionRolePolicy
(PolicyStatement statement) Adds a policy statement to the task execution IAM role.void
addToTaskRolePolicy
(PolicyStatement statement) Adds a policy statement to the task IAM role.void
Adds a volume to the task definition.findContainer
(String containerName) Returns the container that match the provided containerName.static ITaskDefinition
fromTaskDefinitionArn
(software.constructs.Construct scope, String id, String taskDefinitionArn) Imports a task definition from the specified task definition ARN.static ITaskDefinition
fromTaskDefinitionAttributes
(software.constructs.Construct scope, String id, TaskDefinitionAttributes attrs) Create a task definition from a task definition reference.The task launch type compatibility requirement.protected List<ContainerDefinition>
The container definitions.Default container for this task.The amount (in GiB) of ephemeral storage to be allocated to the task.Execution role for this task definition.The name of a family that this task definition is registered to.Public getter method to access list of inference accelerators attached to the instance.Return true if the task definition can be run on an EC2 cluster.Return true if the task definition can be run on a ECS anywhere cluster.Return true if the task definition can be run on a Fargate cluster.The networking mode to use for the containers in the task.Whether this task definition has at least a container that references a specific JSON field of a secret stored in Secrets Manager.The full Amazon Resource Name (ARN) of the task definition.The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.Creates the task execution IAM role if it doesn't already exist.void
Default container for this task.validate()
Validates the task definition.Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize
Methods inherited from class software.constructs.Construct
toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.awscdk.core.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
TaskDefinition
protected TaskDefinition(software.amazon.jsii.JsiiObjectRef objRef) -
TaskDefinition
protected TaskDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
TaskDefinition
@Stability(Stable) public TaskDefinition(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TaskDefinitionProps props) Constructs a new instance of the TaskDefinition class.- Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
fromTaskDefinitionArn
@Stability(Stable) @NotNull public static ITaskDefinition fromTaskDefinitionArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String taskDefinitionArn) Imports a task definition from the specified task definition ARN.The task will have a compatibility of EC2+Fargate.
- Parameters:
scope
- This parameter is required.id
- This parameter is required.taskDefinitionArn
- This parameter is required.
-
fromTaskDefinitionAttributes
@Stability(Stable) @NotNull public static ITaskDefinition fromTaskDefinitionAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TaskDefinitionAttributes attrs) Create a task definition from a task definition reference.- 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) Adds a new container to the task definition.- Parameters:
id
- This parameter is required.props
- This parameter is required.
-
addExtension
Adds the specified extension to the task definition.Extension can be used to apply a packaged modification to a task definition.
- Parameters:
extension
- This parameter is required.
-
addFirelensLogRouter
@Stability(Stable) @NotNull public FirelensLogRouter addFirelensLogRouter(@NotNull String id, @NotNull FirelensLogRouterDefinitionOptions props) Adds a firelens log router to the task definition.- Parameters:
id
- This parameter is required.props
- This parameter is required.
-
addInferenceAccelerator
@Stability(Stable) public void addInferenceAccelerator(@NotNull InferenceAccelerator inferenceAccelerator) Adds an inference accelerator to the task definition.- Parameters:
inferenceAccelerator
- This parameter is required.
-
addPlacementConstraint
Adds the specified placement constraint to the task definition.- Parameters:
constraint
- This parameter is required.
-
addToExecutionRolePolicy
Adds a policy statement to the task execution IAM role.- Parameters:
statement
- This parameter is required.
-
addToTaskRolePolicy
Adds a policy statement to the task IAM role.- Parameters:
statement
- This parameter is required.
-
addVolume
Adds a volume to the task definition.- Parameters:
volume
- This parameter is required.
-
findContainer
@Stability(Stable) @Nullable public ContainerDefinition findContainer(@NotNull String containerName) Returns the container that match the provided containerName.- Parameters:
containerName
- This parameter is required.
-
obtainExecutionRole
Creates the task execution IAM role if it doesn't already exist. -
validate
Validates the task definition. -
getCompatibility
The task launch type compatibility requirement.- Specified by:
getCompatibility
in interfaceITaskDefinition
-
getContainers
The container definitions. -
getFamily
The name of a family that this task definition is registered to.A family groups multiple versions of a task definition.
-
getInferenceAccelerators
Public getter method to access list of inference accelerators attached to the instance. -
getIsEc2Compatible
Return true if the task definition can be run on an EC2 cluster.- Specified by:
getIsEc2Compatible
in interfaceITaskDefinition
-
getIsExternalCompatible
Return true if the task definition can be run on a ECS anywhere cluster.- Specified by:
getIsExternalCompatible
in interfaceITaskDefinition
-
getIsFargateCompatible
Return true if the task definition can be run on a Fargate cluster.- Specified by:
getIsFargateCompatible
in interfaceITaskDefinition
-
getNetworkMode
The networking mode to use for the containers in the task.- Specified by:
getNetworkMode
in interfaceITaskDefinition
-
getTaskDefinitionArn
The full Amazon Resource Name (ARN) of the task definition.- Specified by:
getTaskDefinitionArn
in interfaceITaskDefinition
-
getTaskRole
The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.- Specified by:
getTaskRole
in interfaceITaskDefinition
-
getEphemeralStorageGiB
The amount (in GiB) of ephemeral storage to be allocated to the task.Only supported in Fargate platform version 1.4.0 or later.
-
getExecutionRole
Execution role for this task definition.- Specified by:
getExecutionRole
in interfaceITaskDefinition
-
getReferencesSecretJsonField
Whether this task definition has at least a container that references a specific JSON field of a secret stored in Secrets Manager. -
getDefaultContainer
Default container for this task.Load balancers will send traffic to this container. The first essential container that is added to this task will become the default container.
-
setDefaultContainer
Default container for this task.Load balancers will send traffic to this container. The first essential container that is added to this task will become the default container.
-