Class CfnTaskDefinition
- All Implemented Interfaces:
IInspectable,ITaskDefinitionRef,IEnvironmentAware,ITaggable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
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. 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()))
.restartPolicy(RestartPolicyProperty.builder()
.enabled(false)
.ignoredExitCodes(List.of(123))
.restartAttemptPeriod(123)
.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")
.versionConsistency("versionConsistency")
.volumesFrom(List.of(VolumeFromProperty.builder()
.readOnly(false)
.sourceContainer("sourceContainer")
.build()))
.workingDirectory("workingDirectory")
.build()))
.cpu("cpu")
.enableFaultInjection(false)
.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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe authorization configuration details for the Amazon EFS file system.static final classA fluent builder forCfnTaskDefinition.static interfaceTheContainerDefinitionproperty specifies a container definition.static interfaceTheContainerDependencyproperty specifies the dependencies defined for container startup and shutdown.static interfaceTheDeviceproperty specifies an object representing a container instance host device.static interfaceTheDockerVolumeConfigurationproperty specifies a Docker volume configuration and is used when you use Docker volumes.static interfaceThis parameter is specified when you're using an Amazon Elastic File System file system for task storage.static interfaceA list of files containing the environment variables to pass to a container.static interfaceThe amount of ephemeral storage to allocate for the task.static interfaceThe FireLens configuration for the container.static interfaceThe authorization configuration details for Amazon FSx for Windows File Server file system.static interfaceThis parameter is specified when you're using Amazon FSx for Windows File Server file system for task storage.static interfaceTheHealthCheckproperty specifies an object representing a container health check.static interfaceTheHostEntryproperty specifies a hostname and an IP address that are added to the/etc/hostsfile of a container through theextraHostsparameter of itsContainerDefinitionresource.static interfaceTheHostVolumePropertiesproperty specifies details on a container instance bind mount host volume.static interfaceExample:static interfaceThe Linux capabilities to add or remove from the default Docker configuration for a container defined in the task definition.static interfaceA key-value pair object.static interfaceThe Linux-specific options that are applied to the container, such as Linux KernelCapabilities .static interfaceTheLogConfigurationproperty specifies log configuration options to send to a custom log driver for the container.static interfaceThe details for a volume mount point that's used in a container definition.static interfaceThePortMappingproperty specifies a port mapping.static interfaceThe configuration details for the App Mesh proxy.static interfaceThe repository credentials for private registry authentication.static interfaceThe type and amount of a resource to assign to a container.static interfaceYou can enable a restart policy for each container defined in your task definition, to overcome transient failures faster and maintain task availability.static interfaceInformation about the platform for the Amazon ECS service or task.static interfaceAn object representing the secret to expose to your container.static interfaceA list of namespaced kernel parameters to set in the container.static interfaceThe constraint on task placement in the task definition.static interfaceThe container path, mount options, and size of the tmpfs mount.static interfaceTheulimitsettings to pass to the container.static interfaceDetails on a data volume from another container in the same task definition.static interfaceThe data volume configuration for tasks launched using this task definition.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.interfaces.ecs.ITaskDefinitionRef
ITaskDefinitionRef.Jsii$Default, ITaskDefinitionRef.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnTaskDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnTaskDefinition(software.amazon.jsii.JsiiObjectRef objRef) CfnTaskDefinition(software.constructs.Construct scope, String id) Create a newAWS::ECS::TaskDefinition.CfnTaskDefinition(software.constructs.Construct scope, String id, CfnTaskDefinitionProps props) Create a newAWS::ECS::TaskDefinition. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringarnForTaskDefinition(ITaskDefinitionRef resource) The ARN of the task definition.A list of container definitions in JSON format that describe the different containers that make up your task.getCpu()The number ofcpuunits used by the task.Enables fault injection and allows for fault injection requests to be accepted from the task's containers.The ephemeral storage settings to use for tasks run with the task definition.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.The name of a family that this task definition is registered to.Deprecated.this property has been deprecatedThe IPC resource namespace to use for the containers in the task.The amount (in MiB) of memory used by the task.The Docker networking mode to use for the containers in the task.The process namespace to use for the containers in the task.An array of placement constraint objects to use for tasks.The configuration details for the App Mesh proxy.The task launch types the task definition was validated against.The operating system that your tasks definitions run on.getTags()Tag Manager which manages the tags for this resource.The metadata that you apply to the task definition to help you categorize and organize them.A reference to a TaskDefinition resource.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.The list of data volume definitions for the task.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.static BooleanChecks whether the given object is a CfnTaskDefinition.renderProperties(Map<String, Object> props) voidsetContainerDefinitions(List<Object> value) A list of container definitions in JSON format that describe the different containers that make up your task.voidA list of container definitions in JSON format that describe the different containers that make up your task.voidThe number ofcpuunits used by the task.voidsetEnableFaultInjection(Boolean value) Enables fault injection and allows for fault injection requests to be accepted from the task's containers.voidEnables fault injection and allows for fault injection requests to be accepted from the task's containers.voidsetEphemeralStorage(IResolvable value) The ephemeral storage settings to use for tasks run with the task definition.voidThe ephemeral storage settings to use for tasks run with the task definition.voidsetExecutionRoleArn(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.voidThe name of a family that this task definition is registered to.voidsetInferenceAccelerators(List<Object> value) Deprecated.this property has been deprecatedvoidDeprecated.this property has been deprecatedvoidsetIpcMode(String value) The IPC resource namespace to use for the containers in the task.voidThe amount (in MiB) of memory used by the task.voidsetNetworkMode(String value) The Docker networking mode to use for the containers in the task.voidsetPidMode(String value) The process namespace to use for the containers in the task.voidsetPlacementConstraints(List<Object> value) An array of placement constraint objects to use for tasks.voidAn array of placement constraint objects to use for tasks.voidsetProxyConfiguration(IResolvable value) The configuration details for the App Mesh proxy.voidThe configuration details for the App Mesh proxy.voidsetRequiresCompatibilities(List<String> value) The task launch types the task definition was validated against.voidsetRuntimePlatform(IResolvable value) The operating system that your tasks definitions run on.voidThe operating system that your tasks definitions run on.voidsetTagsRaw(List<CfnTag> value) The metadata that you apply to the task definition to help you categorize and organize them.voidsetTaskRoleArn(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.voidsetVolumes(List<Object> value) The list of data volume definitions for the task.voidsetVolumes(IResolvable value) The list of data volume definitions for the task.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
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) Create a newAWS::ECS::TaskDefinition.- 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) Create a newAWS::ECS::TaskDefinition.- 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
-
arnForTaskDefinition
@Stability(Stable) @NotNull public static String arnForTaskDefinition(@NotNull ITaskDefinitionRef resource) - Parameters:
resource- This parameter is required.
-
isCfnTaskDefinition
Checks whether the given object is a CfnTaskDefinition.- Parameters:
x- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- 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:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrTaskDefinitionArn
The ARN of the task definition. -
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getTags
Tag Manager which manages the tags for this resource. -
getTaskDefinitionRef
A reference to a TaskDefinition resource.- Specified by:
getTaskDefinitionRefin interfaceITaskDefinitionRef
-
getContainerDefinitions
A list of container definitions in JSON format that describe the different containers that make up your task.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnTaskDefinition.ContainerDefinitionProperty> -
setContainerDefinitions
A list of container definitions in JSON format that describe the different containers that make up your task. -
setContainerDefinitions
A list of container definitions in JSON format that describe the different containers that make up your task. -
getCpu
The number ofcpuunits used by the task. -
setCpu
The number ofcpuunits used by the task. -
getEnableFaultInjection
Enables fault injection and allows for fault injection requests to be accepted from the task's containers.Returns union: either
BooleanorIResolvable -
setEnableFaultInjection
Enables fault injection and allows for fault injection requests to be accepted from the task's containers. -
setEnableFaultInjection
Enables fault injection and allows for fault injection requests to be accepted from the task's containers. -
getEphemeralStorage
The ephemeral storage settings to use for tasks run with the task definition.Returns union: either
IResolvableorCfnTaskDefinition.EphemeralStorageProperty -
setEphemeralStorage
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
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
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
The name of a family that this task definition is registered to. -
setFamily
The name of a family that this task definition is registered to. -
getInferenceAccelerators
Deprecated.this property has been deprecatedReturns union: eitherIResolvableor Listinvalid input: '<'eitherIResolvableorCfnTaskDefinition.InferenceAcceleratorProperty> -
setInferenceAccelerators
@Stability(Deprecated) @Deprecated public void setInferenceAccelerators(@Nullable IResolvable value) Deprecated.this property has been deprecated -
setInferenceAccelerators
@Stability(Deprecated) @Deprecated public void setInferenceAccelerators(@Nullable List<Object> value) Deprecated.this property has been deprecated -
getIpcMode
The IPC resource namespace to use for the containers in the task. -
setIpcMode
The IPC resource namespace to use for the containers in the task. -
getMemory
The amount (in MiB) of memory used by the task. -
setMemory
The amount (in MiB) of memory used by the task. -
getNetworkMode
The Docker networking mode to use for the containers in the task. -
setNetworkMode
The Docker networking mode to use for the containers in the task. -
getPidMode
The process namespace to use for the containers in the task. -
setPidMode
The process namespace to use for the containers in the task. -
getPlacementConstraints
An array of placement constraint objects to use for tasks.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnTaskDefinition.TaskDefinitionPlacementConstraintProperty> -
setPlacementConstraints
An array of placement constraint objects to use for tasks. -
setPlacementConstraints
An array of placement constraint objects to use for tasks. -
getProxyConfiguration
The configuration details for the App Mesh proxy.Returns union: either
IResolvableorCfnTaskDefinition.ProxyConfigurationProperty -
setProxyConfiguration
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
The task launch types the task definition was validated against. -
setRequiresCompatibilities
The task launch types the task definition was validated against. -
getRuntimePlatform
The operating system that your tasks definitions run on.Returns union: either
IResolvableorCfnTaskDefinition.RuntimePlatformProperty -
setRuntimePlatform
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
The metadata that you apply to the task definition to help you categorize and organize them. -
setTagsRaw
The metadata that you apply to the task definition to help you categorize and organize them. -
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
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
The list of data volume definitions for the task.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnTaskDefinition.VolumeProperty> -
setVolumes
The list of data volume definitions for the task. -
setVolumes
The list of data volume definitions for the task.
-