@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:38.748Z") @Stability(value=Stable) public class TaskDefinition extends Resource implements ITaskDefinition
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());
| Modifier and Type | Class and Description |
|---|---|
static class |
TaskDefinition.Builder
A fluent builder for
TaskDefinition. |
software.amazon.jsii.JsiiObject.InitializationModeITaskDefinition.Jsii$Default, ITaskDefinition.Jsii$Proxy| Modifier | Constructor and Description |
|---|---|
|
TaskDefinition(software.constructs.Construct scope,
String id,
TaskDefinitionProps props)
Constructs a new instance of the TaskDefinition class.
|
protected |
TaskDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
TaskDefinition(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
ContainerDefinition |
addContainer(String id,
ContainerDefinitionOptions props)
Adds a new container to the task definition.
|
void |
addExtension(ITaskDefinitionExtension extension)
Adds the specified extension to the task definition.
|
FirelensLogRouter |
addFirelensLogRouter(String id,
FirelensLogRouterDefinitionOptions props)
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 |
addVolume(Volume volume)
Adds a volume to the task definition.
|
ContainerDefinition |
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.
|
Compatibility |
getCompatibility()
The task launch type compatibility requirement.
|
protected List<ContainerDefinition> |
getContainers()
The container definitions.
|
ContainerDefinition |
getDefaultContainer()
Default container for this task.
|
Number |
getEphemeralStorageGiB()
The amount (in GiB) of ephemeral storage to be allocated to the task.
|
IRole |
getExecutionRole()
Execution role for this task definition.
|
String |
getFamily()
The name of a family that this task definition is registered to.
|
List<InferenceAccelerator> |
getInferenceAccelerators()
Public getter method to access list of inference accelerators attached to the instance.
|
Boolean |
getIsEc2Compatible()
Return true if the task definition can be run on an EC2 cluster.
|
Boolean |
getIsExternalCompatible()
Return true if the task definition can be run on a ECS anywhere cluster.
|
Boolean |
getIsFargateCompatible()
Return true if the task definition can be run on a Fargate cluster.
|
NetworkMode |
getNetworkMode()
The networking mode to use for the containers in the task.
|
Boolean |
getReferencesSecretJsonField()
Whether this task definition has at least a container that references a specific JSON field of a secret stored in Secrets Manager.
|
String |
getTaskDefinitionArn()
The full Amazon Resource Name (ARN) of the task definition.
|
IRole |
getTaskRole()
The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.
|
Grant |
grantRun(IGrantable grantee)
Grants permissions to run this task definition.
|
IRole |
obtainExecutionRole()
Creates the task execution IAM role if it doesn't already exist.
|
void |
setDefaultContainer(ContainerDefinition value)
Default container for this task.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourcejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapplyRemovalPolicy, getEnv, getStackprotected TaskDefinition(software.amazon.jsii.JsiiObjectRef objRef)
protected TaskDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public TaskDefinition(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
TaskDefinitionProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable) @NotNull public static ITaskDefinition fromTaskDefinitionArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String taskDefinitionArn)
The task will have a compatibility of EC2+Fargate.
scope - This parameter is required.id - This parameter is required.taskDefinitionArn - This parameter is required.@Stability(value=Stable) @NotNull public static ITaskDefinition fromTaskDefinitionAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TaskDefinitionAttributes attrs)
scope - This parameter is required.id - This parameter is required.attrs - This parameter is required.@Stability(value=Stable) @NotNull public ContainerDefinition addContainer(@NotNull String id, @NotNull ContainerDefinitionOptions props)
id - This parameter is required.props - This parameter is required.@Stability(value=Stable)
public void addExtension(@NotNull
ITaskDefinitionExtension extension)
Extension can be used to apply a packaged modification to a task definition.
extension - This parameter is required.@Stability(value=Stable) @NotNull public FirelensLogRouter addFirelensLogRouter(@NotNull String id, @NotNull FirelensLogRouterDefinitionOptions props)
id - This parameter is required.props - This parameter is required.@Stability(value=Stable)
public void addInferenceAccelerator(@NotNull
InferenceAccelerator inferenceAccelerator)
inferenceAccelerator - This parameter is required.@Stability(value=Stable)
public void addPlacementConstraint(@NotNull
PlacementConstraint constraint)
constraint - This parameter is required.@Stability(value=Stable)
public void addToExecutionRolePolicy(@NotNull
PolicyStatement statement)
statement - This parameter is required.@Stability(value=Stable)
public void addToTaskRolePolicy(@NotNull
PolicyStatement statement)
statement - This parameter is required.@Stability(value=Stable)
public void addVolume(@NotNull
Volume volume)
volume - This parameter is required.@Stability(value=Stable) @Nullable public ContainerDefinition findContainer(@NotNull String containerName)
containerName - This parameter is required.@Stability(value=Stable) @NotNull public Grant grantRun(@NotNull IGrantable grantee)
This will grant the following permissions:
grantee - Principal to grant consume rights to. This parameter is required.@Stability(value=Stable) @NotNull public IRole obtainExecutionRole()
@Stability(value=Stable) @NotNull public Compatibility getCompatibility()
getCompatibility in interface ITaskDefinition@Stability(value=Stable) @NotNull protected List<ContainerDefinition> getContainers()
@Stability(value=Stable) @NotNull public String getFamily()
A family groups multiple versions of a task definition.
@Stability(value=Stable) @NotNull public List<InferenceAccelerator> getInferenceAccelerators()
@Stability(value=Stable) @NotNull public Boolean getIsEc2Compatible()
getIsEc2Compatible in interface ITaskDefinition@Stability(value=Stable) @NotNull public Boolean getIsExternalCompatible()
getIsExternalCompatible in interface ITaskDefinition@Stability(value=Stable) @NotNull public Boolean getIsFargateCompatible()
getIsFargateCompatible in interface ITaskDefinition@Stability(value=Stable) @NotNull public NetworkMode getNetworkMode()
getNetworkMode in interface ITaskDefinition@Stability(value=Stable) @NotNull public String getTaskDefinitionArn()
getTaskDefinitionArn in interface ITaskDefinition@Stability(value=Stable) @NotNull public IRole getTaskRole()
getTaskRole in interface ITaskDefinition@Stability(value=Stable) @Nullable public Number getEphemeralStorageGiB()
Only supported in Fargate platform version 1.4.0 or later.
@Stability(value=Stable) @Nullable public IRole getExecutionRole()
getExecutionRole in interface ITaskDefinition@Stability(value=Stable) @Nullable public Boolean getReferencesSecretJsonField()
@Stability(value=Stable) @Nullable public ContainerDefinition getDefaultContainer()
Load balancers will send traffic to this container. The first essential container that is added to this task will become the default container.
@Stability(value=Stable)
public void setDefaultContainer(@Nullable
ContainerDefinition value)
Load balancers will send traffic to this container. The first essential container that is added to this task will become the default container.
Copyright © 2022. All rights reserved.