Class CfnTaskDefinition
Registers a new task definition from the supplied family
and containerDefinitions
.
Inherited Members
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CfnTaskDefinition : CfnResource, IInspectable, ITaggable
Syntax (vb)
Public Class CfnTaskDefinition
Inherits CfnResource
Implements IInspectable, ITaggable
Remarks
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 .
See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-taskdefinition.html
CloudformationResource: AWS::ECS::TaskDefinition
ExampleMetadata: fixture=_generated
Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ECS;
var cfnTaskDefinition = new CfnTaskDefinition(this, "MyCfnTaskDefinition", new CfnTaskDefinitionProps {
ContainerDefinitions = new [] { new ContainerDefinitionProperty {
Image = "image",
Name = "name",
// the properties below are optional
Command = new [] { "command" },
Cpu = 123,
CredentialSpecs = new [] { "credentialSpecs" },
DependsOn = new [] { new ContainerDependencyProperty {
Condition = "condition",
ContainerName = "containerName"
} },
DisableNetworking = false,
DnsSearchDomains = new [] { "dnsSearchDomains" },
DnsServers = new [] { "dnsServers" },
DockerLabels = new Dictionary<string, string> {
{ "dockerLabelsKey", "dockerLabels" }
},
DockerSecurityOptions = new [] { "dockerSecurityOptions" },
EntryPoint = new [] { "entryPoint" },
Environment = new [] { new KeyValuePairProperty {
Name = "name",
Value = "value"
} },
EnvironmentFiles = new [] { new EnvironmentFileProperty {
Type = "type",
Value = "value"
} },
Essential = false,
ExtraHosts = new [] { new HostEntryProperty {
Hostname = "hostname",
IpAddress = "ipAddress"
} },
FirelensConfiguration = new FirelensConfigurationProperty {
Options = new Dictionary<string, string> {
{ "optionsKey", "options" }
},
Type = "type"
},
HealthCheck = new HealthCheckProperty {
Command = new [] { "command" },
Interval = 123,
Retries = 123,
StartPeriod = 123,
Timeout = 123
},
Hostname = "hostname",
Interactive = false,
Links = new [] { "links" },
LinuxParameters = new LinuxParametersProperty {
Capabilities = new KernelCapabilitiesProperty {
Add = new [] { "add" },
Drop = new [] { "drop" }
},
Devices = new [] { new DeviceProperty {
ContainerPath = "containerPath",
HostPath = "hostPath",
Permissions = new [] { "permissions" }
} },
InitProcessEnabled = false,
MaxSwap = 123,
SharedMemorySize = 123,
Swappiness = 123,
Tmpfs = new [] { new TmpfsProperty {
Size = 123,
// the properties below are optional
ContainerPath = "containerPath",
MountOptions = new [] { "mountOptions" }
} }
},
LogConfiguration = new LogConfigurationProperty {
LogDriver = "logDriver",
// the properties below are optional
Options = new Dictionary<string, string> {
{ "optionsKey", "options" }
},
SecretOptions = new [] { new SecretProperty {
Name = "name",
ValueFrom = "valueFrom"
} }
},
Memory = 123,
MemoryReservation = 123,
MountPoints = new [] { new MountPointProperty {
ContainerPath = "containerPath",
ReadOnly = false,
SourceVolume = "sourceVolume"
} },
PortMappings = new [] { new PortMappingProperty {
AppProtocol = "appProtocol",
ContainerPort = 123,
ContainerPortRange = "containerPortRange",
HostPort = 123,
Name = "name",
Protocol = "protocol"
} },
Privileged = false,
PseudoTerminal = false,
ReadonlyRootFilesystem = false,
RepositoryCredentials = new RepositoryCredentialsProperty {
CredentialsParameter = "credentialsParameter"
},
ResourceRequirements = new [] { new ResourceRequirementProperty {
Type = "type",
Value = "value"
} },
Secrets = new [] { new SecretProperty {
Name = "name",
ValueFrom = "valueFrom"
} },
StartTimeout = 123,
StopTimeout = 123,
SystemControls = new [] { new SystemControlProperty {
Namespace = "namespace",
Value = "value"
} },
Ulimits = new [] { new UlimitProperty {
HardLimit = 123,
Name = "name",
SoftLimit = 123
} },
User = "user",
VolumesFrom = new [] { new VolumeFromProperty {
ReadOnly = false,
SourceContainer = "sourceContainer"
} },
WorkingDirectory = "workingDirectory"
} },
Cpu = "cpu",
EphemeralStorage = new EphemeralStorageProperty {
SizeInGiB = 123
},
ExecutionRoleArn = "executionRoleArn",
Family = "family",
InferenceAccelerators = new [] { new InferenceAcceleratorProperty {
DeviceName = "deviceName",
DeviceType = "deviceType"
} },
IpcMode = "ipcMode",
Memory = "memory",
NetworkMode = "networkMode",
PidMode = "pidMode",
PlacementConstraints = new [] { new TaskDefinitionPlacementConstraintProperty {
Type = "type",
// the properties below are optional
Expression = "expression"
} },
ProxyConfiguration = new ProxyConfigurationProperty {
ContainerName = "containerName",
// the properties below are optional
ProxyConfigurationProperties = new [] { new KeyValuePairProperty {
Name = "name",
Value = "value"
} },
Type = "type"
},
RequiresCompatibilities = new [] { "requiresCompatibilities" },
RuntimePlatform = new RuntimePlatformProperty {
CpuArchitecture = "cpuArchitecture",
OperatingSystemFamily = "operatingSystemFamily"
},
Tags = new [] { new CfnTag {
Key = "key",
Value = "value"
} },
TaskRoleArn = "taskRoleArn",
Volumes = new [] { new VolumeProperty {
ConfiguredAtLaunch = false,
DockerVolumeConfiguration = new DockerVolumeConfigurationProperty {
Autoprovision = false,
Driver = "driver",
DriverOpts = new Dictionary<string, string> {
{ "driverOptsKey", "driverOpts" }
},
Labels = new Dictionary<string, string> {
{ "labelsKey", "labels" }
},
Scope = "scope"
},
EfsVolumeConfiguration = new EFSVolumeConfigurationProperty {
FilesystemId = "filesystemId",
// the properties below are optional
AuthorizationConfig = new AuthorizationConfigProperty {
AccessPointId = "accessPointId",
Iam = "iam"
},
RootDirectory = "rootDirectory",
TransitEncryption = "transitEncryption",
TransitEncryptionPort = 123
},
FSxWindowsFileServerVolumeConfiguration = new FSxWindowsFileServerVolumeConfigurationProperty {
FileSystemId = "fileSystemId",
RootDirectory = "rootDirectory",
// the properties below are optional
AuthorizationConfig = new FSxAuthorizationConfigProperty {
CredentialsParameter = "credentialsParameter",
Domain = "domain"
}
},
Host = new HostVolumePropertiesProperty {
SourcePath = "sourcePath"
},
Name = "name"
} }
});
Synopsis
Constructors
CfnTaskDefinition(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CfnTaskDefinition(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
CfnTaskDefinition(Construct, String, ICfnTaskDefinitionProps) |
Properties
AttrTaskDefinitionArn | The ARN of the task definition. |
CFN_RESOURCE_TYPE_NAME | The CloudFormation resource type name for this resource class. |
CfnProperties | |
ContainerDefinitions | A list of container definitions in JSON format that describe the different containers that make up your task. |
Cpu | The number of |
EphemeralStorage | The ephemeral storage settings to use for tasks run with the task definition. |
ExecutionRoleArn | 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. |
Family | The name of a family that this task definition is registered to. |
InferenceAccelerators | The Elastic Inference accelerators to use for the containers in the task. |
IpcMode | The IPC resource namespace to use for the containers in the task. |
Memory | The amount (in MiB) of memory used by the task. |
NetworkMode | The Docker networking mode to use for the containers in the task. |
PidMode | The process namespace to use for the containers in the task. |
PlacementConstraints | An array of placement constraint objects to use for tasks. |
ProxyConfiguration | The configuration details for the App Mesh proxy. |
RequiresCompatibilities | The task launch types the task definition was validated against. |
RuntimePlatform | The operating system that your tasks definitions run on. |
Tags | Tag Manager which manages the tags for this resource. |
TagsRaw | The metadata that you apply to the task definition to help you categorize and organize them. |
TaskRoleArn | 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. |
Volumes | The list of data volume definitions for the task. |
Methods
Inspect(TreeInspector) | Examines the CloudFormation resource and discloses attributes. |
RenderProperties(IDictionary<String, Object>) |
Constructors
CfnTaskDefinition(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CfnTaskDefinition(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CfnTaskDefinition(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CfnTaskDefinition(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
CfnTaskDefinition(Construct, String, ICfnTaskDefinitionProps)
public CfnTaskDefinition(Construct scope, string id, ICfnTaskDefinitionProps props = null)
Parameters
- scope Constructs.Construct
Scope in which this resource is defined.
- id System.String
Construct identifier for this resource (unique in its scope).
- props ICfnTaskDefinitionProps
Resource properties.
Properties
AttrTaskDefinitionArn
The ARN of the task definition.
public virtual string AttrTaskDefinitionArn { get; }
Property Value
System.String
Remarks
CloudformationAttribute: TaskDefinitionArn
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value
System.String
CfnProperties
protected override IDictionary<string, object> CfnProperties { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>
Overrides
ContainerDefinitions
A list of container definitions in JSON format that describe the different containers that make up your task.
public virtual object ContainerDefinitions { get; set; }
Property Value
System.Object
Cpu
The number of cpu
units used by the task.
public virtual string Cpu { get; set; }
Property Value
System.String
EphemeralStorage
The ephemeral storage settings to use for tasks run with the task definition.
public virtual object EphemeralStorage { get; set; }
Property Value
System.Object
ExecutionRoleArn
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.
public virtual string ExecutionRoleArn { get; set; }
Property Value
System.String
Family
The name of a family that this task definition is registered to.
public virtual string Family { get; set; }
Property Value
System.String
InferenceAccelerators
The Elastic Inference accelerators to use for the containers in the task.
public virtual object InferenceAccelerators { get; set; }
Property Value
System.Object
IpcMode
The IPC resource namespace to use for the containers in the task.
public virtual string IpcMode { get; set; }
Property Value
System.String
Memory
The amount (in MiB) of memory used by the task.
public virtual string Memory { get; set; }
Property Value
System.String
NetworkMode
The Docker networking mode to use for the containers in the task.
public virtual string NetworkMode { get; set; }
Property Value
System.String
PidMode
The process namespace to use for the containers in the task.
public virtual string PidMode { get; set; }
Property Value
System.String
PlacementConstraints
An array of placement constraint objects to use for tasks.
public virtual object PlacementConstraints { get; set; }
Property Value
System.Object
ProxyConfiguration
The configuration details for the App Mesh proxy.
public virtual object ProxyConfiguration { get; set; }
Property Value
System.Object
RequiresCompatibilities
The task launch types the task definition was validated against.
public virtual string[] RequiresCompatibilities { get; set; }
Property Value
System.String[]
RuntimePlatform
The operating system that your tasks definitions run on.
public virtual object RuntimePlatform { get; set; }
Property Value
System.Object
Tags
Tag Manager which manages the tags for this resource.
public virtual TagManager Tags { get; }
Property Value
TagsRaw
The metadata that you apply to the task definition to help you categorize and organize them.
public virtual ICfnTag[] TagsRaw { get; set; }
Property Value
ICfnTag[]
TaskRoleArn
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.
public virtual string TaskRoleArn { get; set; }
Property Value
System.String
Volumes
The list of data volume definitions for the task.
public virtual object Volumes { get; set; }
Property Value
System.Object
Methods
Inspect(TreeInspector)
Examines the CloudFormation resource and discloses attributes.
public virtual void Inspect(TreeInspector inspector)
Parameters
- inspector TreeInspector
tree inspector to collect and process attributes.
RenderProperties(IDictionary<String, Object>)
protected override IDictionary<string, object> RenderProperties(IDictionary<string, object> props)
Parameters
- props System.Collections.Generic.IDictionary<System.String, System.Object>
Returns
System.Collections.Generic.IDictionary<System.String, System.Object>