Show / Hide Table of Contents

Class TaskDefinition

The base class for all task definitions.

Inheritance
System.Object
Construct
Resource
TaskDefinition
Ec2TaskDefinition
FargateTaskDefinition
Implements
ITaskDefinition
IResource
IConstruct
Constructs.IConstruct
IDependable
Inherited Members
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(String, IArnComponents)
Resource.GetResourceNameAttribute(String)
Resource.Env
Resource.PhysicalName
Resource.Stack
Construct.IsConstruct(Object)
Construct.OnPrepare()
Construct.OnSynthesize(ISynthesisSession)
Construct.OnValidate()
Construct.Prepare()
Construct.Synthesize(ISynthesisSession)
Construct.Node
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.AWS.ECS.dll
Syntax (csharp)
public class TaskDefinition : Resource, ITaskDefinition, IResource, IConstruct, IConstruct, IDependable
Syntax (vb)
Public Class TaskDefinition
    Inherits Resource
    Implements ITaskDefinition, IResource, IConstruct, IConstruct, IDependable

Synopsis

Constructors

TaskDefinition(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

TaskDefinition(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

TaskDefinition(Construct, String, ITaskDefinitionProps)

Constructs a new instance of the TaskDefinition class.

Properties

Compatibility

The task launch type compatiblity requirement.

Containers

The container definitions.

DefaultContainer

Default container for this task.

ExecutionRole

Execution role for this task definition.

Family

The name of a family that this task definition is registered to.

IsEc2Compatible

Return true if the task definition can be run on an EC2 cluster.

IsFargateCompatible

Return true if the task definition can be run on a Fargate cluster.

NetworkMode

The networking mode to use for the containers in the task.

ReferencesSecretJsonField

Whether this task definition has at least a container that references a specific JSON field of a secret stored in Secrets Manager.

TaskDefinitionArn

The full Amazon Resource Name (ARN) of the task definition.

TaskRole

The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.

Methods

AddContainer(String, IContainerDefinitionOptions)

Adds a new container to the task definition.

AddExtension(ITaskDefinitionExtension)

Adds the specified extention to the task definition.

AddFirelensLogRouter(String, IFirelensLogRouterDefinitionOptions)

Adds a firelens log router to the task definition.

AddPlacementConstraint(PlacementConstraint)

Adds the specified placement constraint to the task definition.

AddToExecutionRolePolicy(PolicyStatement)

Adds a policy statement to the task execution IAM role.

AddToTaskRolePolicy(PolicyStatement)

Adds a policy statement to the task IAM role.

AddVolume(IVolume)

Adds a volume to the task definition.

FromTaskDefinitionArn(Construct, String, String)

Imports a task definition from the specified task definition ARN.

ObtainExecutionRole()

Creates the task execution IAM role if it doesn't already exist.

Validate()

Validates the task definition.

Constructors

TaskDefinition(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected TaskDefinition(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

TaskDefinition(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected TaskDefinition(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

TaskDefinition(Construct, String, ITaskDefinitionProps)

Constructs a new instance of the TaskDefinition class.

public TaskDefinition(Construct scope, string id, ITaskDefinitionProps props)
Parameters
scope Constructs.Construct
id System.String
props ITaskDefinitionProps

Properties

Compatibility

The task launch type compatiblity requirement.

public virtual Compatibility Compatibility { get; }
Property Value

Compatibility

Containers

The container definitions.

protected virtual ContainerDefinition[] Containers { get; }
Property Value

ContainerDefinition[]

DefaultContainer

Default container for this task.

public virtual ContainerDefinition DefaultContainer { get; set; }
Property Value

ContainerDefinition

Remarks

Load balancers will send traffic to this container. The first essential container that is added to this task will become the default container.

ExecutionRole

Execution role for this task definition.

public virtual IRole ExecutionRole { get; }
Property Value

IRole

Family

The name of a family that this task definition is registered to.

public virtual string Family { get; }
Property Value

System.String

Remarks

A family groups multiple versions of a task definition.

IsEc2Compatible

Return true if the task definition can be run on an EC2 cluster.

public virtual bool IsEc2Compatible { get; }
Property Value

System.Boolean

IsFargateCompatible

Return true if the task definition can be run on a Fargate cluster.

public virtual bool IsFargateCompatible { get; }
Property Value

System.Boolean

NetworkMode

The networking mode to use for the containers in the task.

public virtual NetworkMode NetworkMode { get; }
Property Value

NetworkMode

ReferencesSecretJsonField

Whether this task definition has at least a container that references a specific JSON field of a secret stored in Secrets Manager.

public virtual Nullable<bool> ReferencesSecretJsonField { get; }
Property Value

System.Nullable<System.Boolean>

TaskDefinitionArn

The full Amazon Resource Name (ARN) of the task definition.

public virtual string TaskDefinitionArn { get; }
Property Value

System.String

Remarks

Attribute: true

TaskRole

The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.

public virtual IRole TaskRole { get; }
Property Value

IRole

Methods

AddContainer(String, IContainerDefinitionOptions)

Adds a new container to the task definition.

public virtual ContainerDefinition AddContainer(string id, IContainerDefinitionOptions props)
Parameters
id System.String
props IContainerDefinitionOptions
Returns

ContainerDefinition

AddExtension(ITaskDefinitionExtension)

Adds the specified extention to the task definition.

public virtual void AddExtension(ITaskDefinitionExtension extension)
Parameters
extension ITaskDefinitionExtension
Remarks

Extension can be used to apply a packaged modification to a task definition.

AddFirelensLogRouter(String, IFirelensLogRouterDefinitionOptions)

Adds a firelens log router to the task definition.

public virtual FirelensLogRouter AddFirelensLogRouter(string id, IFirelensLogRouterDefinitionOptions props)
Parameters
id System.String
props IFirelensLogRouterDefinitionOptions
Returns

FirelensLogRouter

AddPlacementConstraint(PlacementConstraint)

Adds the specified placement constraint to the task definition.

public virtual void AddPlacementConstraint(PlacementConstraint constraint)
Parameters
constraint PlacementConstraint

AddToExecutionRolePolicy(PolicyStatement)

Adds a policy statement to the task execution IAM role.

public virtual void AddToExecutionRolePolicy(PolicyStatement statement)
Parameters
statement PolicyStatement

AddToTaskRolePolicy(PolicyStatement)

Adds a policy statement to the task IAM role.

public virtual void AddToTaskRolePolicy(PolicyStatement statement)
Parameters
statement PolicyStatement

AddVolume(IVolume)

Adds a volume to the task definition.

public virtual void AddVolume(IVolume volume)
Parameters
volume IVolume

FromTaskDefinitionArn(Construct, String, String)

Imports a task definition from the specified task definition ARN.

public static ITaskDefinition FromTaskDefinitionArn(Construct scope, string id, string taskDefinitionArn)
Parameters
scope Constructs.Construct
id System.String
taskDefinitionArn System.String
Returns

ITaskDefinition

Remarks

The task will have a compatibility of EC2+Fargate.

ObtainExecutionRole()

Creates the task execution IAM role if it doesn't already exist.

public virtual IRole ObtainExecutionRole()
Returns

IRole

Validate()

Validates the task definition.

protected override string[] Validate()
Returns

System.String[]

Overrides
Construct.Validate()

Implements

ITaskDefinition
IResource
IConstruct
Constructs.IConstruct
IDependable
Back to top Generated by DocFX