CfnTaskDefinition L1 construct
Registers a new task definition from the supplied 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 { aws_ecs as ecs } from 'aws-cdk-lib';
const cfnTaskDefinition = new ecs.CfnTaskDefinition(this, 'MyCfnTaskDefinition', /* all optional props */ {
containerDefinitions: [{
image: 'image',
name: 'name',
// the properties below are optional
command: ['command'],
cpu: 123,
credentialSpecs: ['credentialSpecs'],
dependsOn: [{
condition: 'condition',
containerName: 'containerName',
}],
disableNetworking: false,
dnsSearchDomains: ['dnsSearchDomains'],
dnsServers: ['dnsServers'],
dockerLabels: {
dockerLabelsKey: 'dockerLabels',
},
dockerSecurityOptions: ['dockerSecurityOptions'],
entryPoint: ['entryPoint'],
environment: [{
name: 'name',
value: 'value',
}],
environmentFiles: [{
type: 'type',
value: 'value',
}],
essential: false,
extraHosts: [{
hostname: 'hostname',
ipAddress: 'ipAddress',
}],
firelensConfiguration: {
options: {
optionsKey: 'options',
},
type: 'type',
},
healthCheck: {
command: ['command'],
interval: 123,
retries: 123,
startPeriod: 123,
timeout: 123,
},
hostname: 'hostname',
interactive: false,
links: ['links'],
linuxParameters: {
capabilities: {
add: ['add'],
drop: ['drop'],
},
devices: [{
containerPath: 'containerPath',
hostPath: 'hostPath',
permissions: ['permissions'],
}],
initProcessEnabled: false,
maxSwap: 123,
sharedMemorySize: 123,
swappiness: 123,
tmpfs: [{
size: 123,
// the properties below are optional
containerPath: 'containerPath',
mountOptions: ['mountOptions'],
}],
},
logConfiguration: {
logDriver: 'logDriver',
// the properties below are optional
options: {
optionsKey: 'options',
},
secretOptions: [{
name: 'name',
valueFrom: 'valueFrom',
}],
},
memory: 123,
memoryReservation: 123,
mountPoints: [{
containerPath: 'containerPath',
readOnly: false,
sourceVolume: 'sourceVolume',
}],
portMappings: [{
appProtocol: 'appProtocol',
containerPort: 123,
containerPortRange: 'containerPortRange',
hostPort: 123,
name: 'name',
protocol: 'protocol',
}],
privileged: false,
pseudoTerminal: false,
readonlyRootFilesystem: false,
repositoryCredentials: {
credentialsParameter: 'credentialsParameter',
},
resourceRequirements: [{
type: 'type',
value: 'value',
}],
restartPolicy: {
enabled: false,
ignoredExitCodes: [123],
restartAttemptPeriod: 123,
},
secrets: [{
name: 'name',
valueFrom: 'valueFrom',
}],
startTimeout: 123,
stopTimeout: 123,
systemControls: [{
namespace: 'namespace',
value: 'value',
}],
ulimits: [{
hardLimit: 123,
name: 'name',
softLimit: 123,
}],
user: 'user',
versionConsistency: 'versionConsistency',
volumesFrom: [{
readOnly: false,
sourceContainer: 'sourceContainer',
}],
workingDirectory: 'workingDirectory',
}],
cpu: 'cpu',
enableFaultInjection: false,
ephemeralStorage: {
sizeInGiB: 123,
},
executionRoleArn: 'executionRoleArn',
family: 'family',
inferenceAccelerators: [{
deviceName: 'deviceName',
deviceType: 'deviceType',
}],
ipcMode: 'ipcMode',
memory: 'memory',
networkMode: 'networkMode',
pidMode: 'pidMode',
placementConstraints: [{
type: 'type',
// the properties below are optional
expression: 'expression',
}],
proxyConfiguration: {
containerName: 'containerName',
// the properties below are optional
proxyConfigurationProperties: [{
name: 'name',
value: 'value',
}],
type: 'type',
},
requiresCompatibilities: ['requiresCompatibilities'],
runtimePlatform: {
cpuArchitecture: 'cpuArchitecture',
operatingSystemFamily: 'operatingSystemFamily',
},
tags: [{
key: 'key',
value: 'value',
}],
taskRoleArn: 'taskRoleArn',
volumes: [{
configuredAtLaunch: false,
dockerVolumeConfiguration: {
autoprovision: false,
driver: 'driver',
driverOpts: {
driverOptsKey: 'driverOpts',
},
labels: {
labelsKey: 'labels',
},
scope: 'scope',
},
efsVolumeConfiguration: {
filesystemId: 'filesystemId',
// the properties below are optional
authorizationConfig: {
accessPointId: 'accessPointId',
iam: 'iam',
},
rootDirectory: 'rootDirectory',
transitEncryption: 'transitEncryption',
transitEncryptionPort: 123,
},
fSxWindowsFileServerVolumeConfiguration: {
fileSystemId: 'fileSystemId',
rootDirectory: 'rootDirectory',
// the properties below are optional
authorizationConfig: {
credentialsParameter: 'credentialsParameter',
domain: 'domain',
},
},
host: {
sourcePath: 'sourcePath',
},
name: 'name',
s3FilesVolumeConfiguration: {
fileSystemArn: 'fileSystemArn',
// the properties below are optional
accessPointArn: 'accessPointArn',
rootDirectory: 'rootDirectory',
transitEncryptionPort: 123,
},
}],
});
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ecs as ecs
cfn_task_definition = ecs.CfnTaskDefinition(self, "MyCfnTaskDefinition",
container_definitions=[ecs.CfnTaskDefinition.ContainerDefinitionProperty(
image="image",
name="name",
# the properties below are optional
command=["command"],
cpu=123,
credential_specs=["credentialSpecs"],
depends_on=[ecs.CfnTaskDefinition.ContainerDependencyProperty(
condition="condition",
container_name="containerName"
)],
disable_networking=False,
dns_search_domains=["dnsSearchDomains"],
dns_servers=["dnsServers"],
docker_labels={
"docker_labels_key": "dockerLabels"
},
docker_security_options=["dockerSecurityOptions"],
entry_point=["entryPoint"],
environment=[ecs.CfnTaskDefinition.KeyValuePairProperty(
name="name",
value="value"
)],
environment_files=[ecs.CfnTaskDefinition.EnvironmentFileProperty(
type="type",
value="value"
)],
essential=False,
extra_hosts=[ecs.CfnTaskDefinition.HostEntryProperty(
hostname="hostname",
ip_address="ipAddress"
)],
firelens_configuration=ecs.CfnTaskDefinition.FirelensConfigurationProperty(
options={
"options_key": "options"
},
type="type"
),
health_check=ecs.CfnTaskDefinition.HealthCheckProperty(
command=["command"],
interval=123,
retries=123,
start_period=123,
timeout=123
),
hostname="hostname",
interactive=False,
links=["links"],
linux_parameters=ecs.CfnTaskDefinition.LinuxParametersProperty(
capabilities=ecs.CfnTaskDefinition.KernelCapabilitiesProperty(
add=["add"],
drop=["drop"]
),
devices=[ecs.CfnTaskDefinition.DeviceProperty(
container_path="containerPath",
host_path="hostPath",
permissions=["permissions"]
)],
init_process_enabled=False,
max_swap=123,
shared_memory_size=123,
swappiness=123,
tmpfs=[ecs.CfnTaskDefinition.TmpfsProperty(
size=123,
# the properties below are optional
container_path="containerPath",
mount_options=["mountOptions"]
)]
),
log_configuration=ecs.CfnTaskDefinition.LogConfigurationProperty(
log_driver="logDriver",
# the properties below are optional
options={
"options_key": "options"
},
secret_options=[ecs.CfnTaskDefinition.SecretProperty(
name="name",
value_from="valueFrom"
)]
),
memory=123,
memory_reservation=123,
mount_points=[ecs.CfnTaskDefinition.MountPointProperty(
container_path="containerPath",
read_only=False,
source_volume="sourceVolume"
)],
port_mappings=[ecs.CfnTaskDefinition.PortMappingProperty(
app_protocol="appProtocol",
container_port=123,
container_port_range="containerPortRange",
host_port=123,
name="name",
protocol="protocol"
)],
privileged=False,
pseudo_terminal=False,
readonly_root_filesystem=False,
repository_credentials=ecs.CfnTaskDefinition.RepositoryCredentialsProperty(
credentials_parameter="credentialsParameter"
),
resource_requirements=[ecs.CfnTaskDefinition.ResourceRequirementProperty(
type="type",
value="value"
)],
restart_policy=ecs.CfnTaskDefinition.RestartPolicyProperty(
enabled=False,
ignored_exit_codes=[123],
restart_attempt_period=123
),
secrets=[ecs.CfnTaskDefinition.SecretProperty(
name="name",
value_from="valueFrom"
)],
start_timeout=123,
stop_timeout=123,
system_controls=[ecs.CfnTaskDefinition.SystemControlProperty(
namespace="namespace",
value="value"
)],
ulimits=[ecs.CfnTaskDefinition.UlimitProperty(
hard_limit=123,
name="name",
soft_limit=123
)],
user="user",
version_consistency="versionConsistency",
volumes_from=[ecs.CfnTaskDefinition.VolumeFromProperty(
read_only=False,
source_container="sourceContainer"
)],
working_directory="workingDirectory"
)],
cpu="cpu",
enable_fault_injection=False,
ephemeral_storage=ecs.CfnTaskDefinition.EphemeralStorageProperty(
size_in_gi_b=123
),
execution_role_arn="executionRoleArn",
family="family",
inference_accelerators=[ecs.CfnTaskDefinition.InferenceAcceleratorProperty(
device_name="deviceName",
device_type="deviceType"
)],
ipc_mode="ipcMode",
memory="memory",
network_mode="networkMode",
pid_mode="pidMode",
placement_constraints=[ecs.CfnTaskDefinition.TaskDefinitionPlacementConstraintProperty(
type="type",
# the properties below are optional
expression="expression"
)],
proxy_configuration=ecs.CfnTaskDefinition.ProxyConfigurationProperty(
container_name="containerName",
# the properties below are optional
proxy_configuration_properties=[ecs.CfnTaskDefinition.KeyValuePairProperty(
name="name",
value="value"
)],
type="type"
),
requires_compatibilities=["requiresCompatibilities"],
runtime_platform=ecs.CfnTaskDefinition.RuntimePlatformProperty(
cpu_architecture="cpuArchitecture",
operating_system_family="operatingSystemFamily"
),
tags=[CfnTag(
key="key",
value="value"
)],
task_role_arn="taskRoleArn",
volumes=[ecs.CfnTaskDefinition.VolumeProperty(
configured_at_launch=False,
docker_volume_configuration=ecs.CfnTaskDefinition.DockerVolumeConfigurationProperty(
autoprovision=False,
driver="driver",
driver_opts={
"driver_opts_key": "driverOpts"
},
labels={
"labels_key": "labels"
},
scope="scope"
),
efs_volume_configuration=ecs.CfnTaskDefinition.EFSVolumeConfigurationProperty(
filesystem_id="filesystemId",
# the properties below are optional
authorization_config=ecs.CfnTaskDefinition.AuthorizationConfigProperty(
access_point_id="accessPointId",
iam="iam"
),
root_directory="rootDirectory",
transit_encryption="transitEncryption",
transit_encryption_port=123
),
f_sx_windows_file_server_volume_configuration=ecs.CfnTaskDefinition.FSxWindowsFileServerVolumeConfigurationProperty(
file_system_id="fileSystemId",
root_directory="rootDirectory",
# the properties below are optional
authorization_config=ecs.CfnTaskDefinition.FSxAuthorizationConfigProperty(
credentials_parameter="credentialsParameter",
domain="domain"
)
),
host=ecs.CfnTaskDefinition.HostVolumePropertiesProperty(
source_path="sourcePath"
),
name="name",
s3_files_volume_configuration=ecs.CfnTaskDefinition.S3FilesVolumeConfigurationProperty(
file_system_arn="fileSystemArn",
# the properties below are optional
access_point_arn="accessPointArn",
root_directory="rootDirectory",
transit_encryption_port=123
)
)]
)
// 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")
.s3FilesVolumeConfiguration(S3FilesVolumeConfigurationProperty.builder()
.fileSystemArn("fileSystemArn")
// the properties below are optional
.accessPointArn("accessPointArn")
.rootDirectory("rootDirectory")
.transitEncryptionPort(123)
.build())
.build()))
.build();
// Install: dotnet add package Amazon.CDK.Lib
// 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"
} },
RestartPolicy = new RestartPolicyProperty {
Enabled = false,
IgnoredExitCodes = new [] { 123 },
RestartAttemptPeriod = 123
},
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",
VersionConsistency = "versionConsistency",
VolumesFrom = new [] { new VolumeFromProperty {
ReadOnly = false,
SourceContainer = "sourceContainer"
} },
WorkingDirectory = "workingDirectory"
} },
Cpu = "cpu",
EnableFaultInjection = false,
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",
S3FilesVolumeConfiguration = new S3FilesVolumeConfigurationProperty {
FileSystemArn = "fileSystemArn",
// the properties below are optional
AccessPointArn = "accessPointArn",
RootDirectory = "rootDirectory",
TransitEncryptionPort = 123
}
} }
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
cfnTaskDefinition := awscdk.Aws_ecs.NewCfnTaskDefinition(this, jsii.String("MyCfnTaskDefinition"), &CfnTaskDefinitionProps{
ContainerDefinitions: []interface{}{
&ContainerDefinitionProperty{
Image: jsii.String("image"),
Name: jsii.String("name"),
// the properties below are optional
Command: []*string{
jsii.String("command"),
},
Cpu: jsii.Number(123),
CredentialSpecs: []*string{
jsii.String("credentialSpecs"),
},
DependsOn: []interface{}{
&ContainerDependencyProperty{
Condition: jsii.String("condition"),
ContainerName: jsii.String("containerName"),
},
},
DisableNetworking: jsii.Boolean(false),
DnsSearchDomains: []*string{
jsii.String("dnsSearchDomains"),
},
DnsServers: []*string{
jsii.String("dnsServers"),
},
DockerLabels: map[string]*string{
"dockerLabelsKey": jsii.String("dockerLabels"),
},
DockerSecurityOptions: []*string{
jsii.String("dockerSecurityOptions"),
},
EntryPoint: []*string{
jsii.String("entryPoint"),
},
Environment: []interface{}{
&KeyValuePairProperty{
Name: jsii.String("name"),
Value: jsii.String("value"),
},
},
EnvironmentFiles: []interface{}{
&EnvironmentFileProperty{
Type: jsii.String("type"),
Value: jsii.String("value"),
},
},
Essential: jsii.Boolean(false),
ExtraHosts: []interface{}{
&HostEntryProperty{
Hostname: jsii.String("hostname"),
IpAddress: jsii.String("ipAddress"),
},
},
FirelensConfiguration: &FirelensConfigurationProperty{
Options: map[string]*string{
"optionsKey": jsii.String("options"),
},
Type: jsii.String("type"),
},
HealthCheck: &HealthCheckProperty{
Command: []*string{
jsii.String("command"),
},
Interval: jsii.Number(123),
Retries: jsii.Number(123),
StartPeriod: jsii.Number(123),
Timeout: jsii.Number(123),
},
Hostname: jsii.String("hostname"),
Interactive: jsii.Boolean(false),
Links: []*string{
jsii.String("links"),
},
LinuxParameters: &LinuxParametersProperty{
Capabilities: &KernelCapabilitiesProperty{
Add: []*string{
jsii.String("add"),
},
Drop: []*string{
jsii.String("drop"),
},
},
Devices: []interface{}{
&DeviceProperty{
ContainerPath: jsii.String("containerPath"),
HostPath: jsii.String("hostPath"),
Permissions: []*string{
jsii.String("permissions"),
},
},
},
InitProcessEnabled: jsii.Boolean(false),
MaxSwap: jsii.Number(123),
SharedMemorySize: jsii.Number(123),
Swappiness: jsii.Number(123),
Tmpfs: []interface{}{
&TmpfsProperty{
Size: jsii.Number(123),
// the properties below are optional
ContainerPath: jsii.String("containerPath"),
MountOptions: []*string{
jsii.String("mountOptions"),
},
},
},
},
LogConfiguration: &LogConfigurationProperty{
LogDriver: jsii.String("logDriver"),
// the properties below are optional
Options: map[string]*string{
"optionsKey": jsii.String("options"),
},
SecretOptions: []interface{}{
&SecretProperty{
Name: jsii.String("name"),
ValueFrom: jsii.String("valueFrom"),
},
},
},
Memory: jsii.Number(123),
MemoryReservation: jsii.Number(123),
MountPoints: []interface{}{
&MountPointProperty{
ContainerPath: jsii.String("containerPath"),
ReadOnly: jsii.Boolean(false),
SourceVolume: jsii.String("sourceVolume"),
},
},
PortMappings: []interface{}{
&PortMappingProperty{
AppProtocol: jsii.String("appProtocol"),
ContainerPort: jsii.Number(123),
ContainerPortRange: jsii.String("containerPortRange"),
HostPort: jsii.Number(123),
Name: jsii.String("name"),
Protocol: jsii.String("protocol"),
},
},
Privileged: jsii.Boolean(false),
PseudoTerminal: jsii.Boolean(false),
ReadonlyRootFilesystem: jsii.Boolean(false),
RepositoryCredentials: &RepositoryCredentialsProperty{
CredentialsParameter: jsii.String("credentialsParameter"),
},
ResourceRequirements: []interface{}{
&ResourceRequirementProperty{
Type: jsii.String("type"),
Value: jsii.String("value"),
},
},
RestartPolicy: &RestartPolicyProperty{
Enabled: jsii.Boolean(false),
IgnoredExitCodes: []interface{}{
jsii.Number(123),
},
RestartAttemptPeriod: jsii.Number(123),
},
Secrets: []interface{}{
&SecretProperty{
Name: jsii.String("name"),
ValueFrom: jsii.String("valueFrom"),
},
},
StartTimeout: jsii.Number(123),
StopTimeout: jsii.Number(123),
SystemControls: []interface{}{
&SystemControlProperty{
Namespace: jsii.String("namespace"),
Value: jsii.String("value"),
},
},
Ulimits: []interface{}{
&UlimitProperty{
HardLimit: jsii.Number(123),
Name: jsii.String("name"),
SoftLimit: jsii.Number(123),
},
},
User: jsii.String("user"),
VersionConsistency: jsii.String("versionConsistency"),
VolumesFrom: []interface{}{
&VolumeFromProperty{
ReadOnly: jsii.Boolean(false),
SourceContainer: jsii.String("sourceContainer"),
},
},
WorkingDirectory: jsii.String("workingDirectory"),
},
},
Cpu: jsii.String("cpu"),
EnableFaultInjection: jsii.Boolean(false),
EphemeralStorage: &EphemeralStorageProperty{
SizeInGiB: jsii.Number(123),
},
ExecutionRoleArn: jsii.String("executionRoleArn"),
Family: jsii.String("family"),
InferenceAccelerators: []interface{}{
&InferenceAcceleratorProperty{
DeviceName: jsii.String("deviceName"),
DeviceType: jsii.String("deviceType"),
},
},
IpcMode: jsii.String("ipcMode"),
Memory: jsii.String("memory"),
NetworkMode: jsii.String("networkMode"),
PidMode: jsii.String("pidMode"),
PlacementConstraints: []interface{}{
&TaskDefinitionPlacementConstraintProperty{
Type: jsii.String("type"),
// the properties below are optional
Expression: jsii.String("expression"),
},
},
ProxyConfiguration: &ProxyConfigurationProperty{
ContainerName: jsii.String("containerName"),
// the properties below are optional
ProxyConfigurationProperties: []interface{}{
&KeyValuePairProperty{
Name: jsii.String("name"),
Value: jsii.String("value"),
},
},
Type: jsii.String("type"),
},
RequiresCompatibilities: []*string{
jsii.String("requiresCompatibilities"),
},
RuntimePlatform: &RuntimePlatformProperty{
CpuArchitecture: jsii.String("cpuArchitecture"),
OperatingSystemFamily: jsii.String("operatingSystemFamily"),
},
Tags: []CfnTag{
&CfnTag{
Key: jsii.String("key"),
Value: jsii.String("value"),
},
},
TaskRoleArn: jsii.String("taskRoleArn"),
Volumes: []interface{}{
&VolumeProperty{
ConfiguredAtLaunch: jsii.Boolean(false),
DockerVolumeConfiguration: &DockerVolumeConfigurationProperty{
Autoprovision: jsii.Boolean(false),
Driver: jsii.String("driver"),
DriverOpts: map[string]*string{
"driverOptsKey": jsii.String("driverOpts"),
},
Labels: map[string]*string{
"labelsKey": jsii.String("labels"),
},
Scope: jsii.String("scope"),
},
EfsVolumeConfiguration: &EFSVolumeConfigurationProperty{
FilesystemId: jsii.String("filesystemId"),
// the properties below are optional
AuthorizationConfig: &AuthorizationConfigProperty{
AccessPointId: jsii.String("accessPointId"),
Iam: jsii.String("iam"),
},
RootDirectory: jsii.String("rootDirectory"),
TransitEncryption: jsii.String("transitEncryption"),
TransitEncryptionPort: jsii.Number(123),
},
FSxWindowsFileServerVolumeConfiguration: &FSxWindowsFileServerVolumeConfigurationProperty{
FileSystemId: jsii.String("fileSystemId"),
RootDirectory: jsii.String("rootDirectory"),
// the properties below are optional
AuthorizationConfig: &FSxAuthorizationConfigProperty{
CredentialsParameter: jsii.String("credentialsParameter"),
Domain: jsii.String("domain"),
},
},
Host: &HostVolumePropertiesProperty{
SourcePath: jsii.String("sourcePath"),
},
Name: jsii.String("name"),
S3FilesVolumeConfiguration: &S3FilesVolumeConfigurationProperty{
FileSystemArn: jsii.String("fileSystemArn"),
// the properties below are optional
AccessPointArn: jsii.String("accessPointArn"),
RootDirectory: jsii.String("rootDirectory"),
TransitEncryptionPort: jsii.Number(123),
},
},
},
})
Initializer
new CfnTaskDefinition(scope: Construct, id: string, props?: CfnTaskDefinitionProps)
CfnTaskDefinition(scope: Construct, id: str, props: typing.Optional[CfnTaskDefinitionProps] = None)
new CfnTaskDefinition(Construct scope, String id, CfnTaskDefinitionProps props)
new CfnTaskDefinition(Construct scope, string id, CfnTaskDefinitionProps? props = null)
NewCfnTaskDefinition(Scope Construct, Id *string, Props CfnTaskDefinitionProps)
Construct Props
containerDefinitionsoptionalIResolvable | IResolvable | CfnTaskDefinition.ContainerDefinitionProperty[]container_definitionsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ContainerDefinitionProperty]]]containerDefinitionsoptionalIResolvableContainerDefinitionsoptionalIResolvableContainerDefinitionsoptionalinterface{}#notes
For more information about container definition parameters and defaults, see Amazon ECS Task Definitions in the Amazon Elastic Container Service Developer Guide .
notes
If you use the EC2 launch type, this field is optional. Any value can be used. If you use the Fargate launch type, this field is required. You must use one of the following values. The value that you choose determines your range of valid values for the memory parameter.
If you're using the EC2 launch type or the external launch type, this field is optional. Supported values are between 128 CPU units ( 0.125 vCPUs) and 196608 CPU units ( 192 vCPUs).
This field is required for Fargate. For information about the valid values, see Task size in the Amazon Elastic Container Service Developer Guide .
enableFaultInjectionoptionalboolean | IResolvableenable_fault_injectionoptionaltyping.Union[bool, IResolvable]enableFaultInjectionoptionalBooleanEnableFaultInjectionoptionalboolEnableFaultInjectionoptionalinterface{}#The default value is false .
ephemeralStorageoptionalIResolvable | CfnTaskDefinition.EphemeralStoragePropertyephemeral_storageoptionaltyping.Union[IResolvable, EphemeralStorageProperty]ephemeralStorageoptionalIResolvableEphemeralStorageoptionalIResolvableEphemeralStorageoptionalinterface{}#executionRoleArnoptionalstring | IRoleRefexecution_role_arnoptionaltyping.Union[str, IRoleRef]executionRoleArnoptionalStringExecutionRoleArnoptionalstringExecutionRoleArnoptionalinterface{}#notes
For informationabout the required IAM roles for Amazon ECS, see IAM roles for Amazon ECS in the Amazon Elastic Container Service Developer Guide .
notes
Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.
A family groups multiple versions of a task definition. Amazon ECS gives the first task definition that you registered to a family a revision number of 1. Amazon ECS gives sequential revision numbers to each task definition that you add.
To use revision numbers when you update a task definition, specify this property. If you don't specify a value, AWS CloudFormation generates a new task definition each time that you update it.
inferenceAcceleratorsoptionalIResolvable | IResolvable | CfnTaskDefinition.InferenceAcceleratorProperty[]inference_acceleratorsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, InferenceAcceleratorProperty]]]inferenceAcceleratorsoptionalIResolvableInferenceAcceleratorsoptionalIResolvableInferenceAcceleratorsoptionalinterface{}deprecated#ipcModeoptionalstringipc_modeoptionalstripcModeoptionalStringIpcModeoptionalstringIpcModeoptional*string#notes
The valid values are host , task , or none . If host is specified, then all containers within the tasks that specified the host IPC mode on the same container instance share the same IPC resources with the host Amazon EC2 instance. If task is specified, all containers within the specified task share the same IPC resources. If none is specified, then IPC resources within the containers of a task are private and not shared with other containers in a task or on the container instance. If no value is specified, then the IPC resource namespace sharing depends on the Docker daemon setting on the container instance.
If the host IPC mode is used, be aware that there is a heightened risk of undesired IPC namespace expose.
If you are setting namespaced kernel parameters using systemControls for the containers in the task, the following will apply to your IPC resource namespace. For more information, see System Controls in the Amazon Elastic Container Service Developer Guide .
- For tasks that use the
hostIPC mode, IPC namespace relatedsystemControlsare not supported. - For tasks that use the
taskIPC mode, IPC namespace relatedsystemControlswill apply to all containers within a task.
This parameter is not supported for Windows containers or tasks run on AWS Fargate .
notes
If your tasks runs on Amazon EC2 instances, you must specify either a task-level memory value or a container-level memory value. This field is optional and any value can be used. If a task-level memory value is specified, the container-level memory value is optional. For more information regarding container-level memory and memory reservation, see ContainerDefinition .
If your tasks runs on AWS Fargate , this field is required. You must use one of the following values. The value you choose determines your range of valid values for the cpu parameter.
- 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available
cpuvalues: 256 (.25 vCPU) - 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available
cpuvalues: 512 (.5 vCPU) - 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available
cpuvalues: 1024 (1 vCPU) - Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available
cpuvalues: 2048 (2 vCPU) - Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available
cpuvalues: 4096 (4 vCPU) - Between 16 GB and 60 GB in 4 GB increments - Available
cpuvalues: 8192 (8 vCPU)
This option requires Linux platform 1.4.0 or later.
- Between 32GB and 120 GB in 8 GB increments - Available
cpuvalues: 16384 (16 vCPU)
This option requires Linux platform 1.4.0 or later.
networkModeoptionalstringnetwork_modeoptionalstrnetworkModeoptionalStringNetworkModeoptionalstringNetworkModeoptional*string#notes
The valid values are none , bridge , awsvpc , and host . If no network mode is specified, the default is bridge .
For Amazon ECS tasks on Fargate, the awsvpc network mode is required. For Amazon ECS tasks on Amazon EC2 Linux instances, any network mode can be used. For Amazon ECS tasks on Amazon EC2 Windows instances, <default> or awsvpc can be used. If the network mode is set to none , you cannot specify port mappings in your container definitions, and the tasks containers do not have external connectivity. The host and awsvpc network modes offer the highest networking performance for containers because they use the EC2 network stack instead of the virtualized network stack provided by the bridge mode.
With the host and awsvpc network modes, exposed container ports are mapped directly to the corresponding host port (for the host network mode) or the attached elastic network interface port (for the awsvpc network mode), so you cannot take advantage of dynamic host port mappings.
When using the
hostnetwork mode, you should not run containers using the root user (UID 0). It is considered best practice to use a non-root user.
If the network mode is awsvpc , the task is allocated an elastic network interface, and you must specify a NetworkConfiguration value 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 .
If the network mode is host , you cannot run multiple instantiations of the same task on a single container instance when port mappings are used.
pidModeoptionalstringpid_modeoptionalstrpidModeoptionalStringPidModeoptionalstringPidModeoptional*string#notes
The valid values are host or task . On Fargate for Linux containers, the only valid value is task . For example, monitoring sidecars might need pidMode to access information about other containers running in the same task.
If host is specified, all containers within the tasks that specified the host PID mode on the same container instance share the same process namespace with the host Amazon EC2 instance.
If task is specified, all containers within the specified task share the same process namespace.
If no value is specified, the The default is a private namespace for each container.
If the host PID mode is used, there's a heightened risk of undesired process namespace exposure.
This parameter is not supported for Windows containers. > This parameter is only supported for tasks that are hosted on AWS Fargate if the tasks are using platform version
1.4.0or later (Linux). This isn't supported for Windows containers on Fargate.
placementConstraintsoptionalIResolvable | IResolvable | CfnTaskDefinition.TaskDefinitionPlacementConstraintProperty[]placement_constraintsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, TaskDefinitionPlacementConstraintProperty]]]placementConstraintsoptionalIResolvablePlacementConstraintsoptionalIResolvablePlacementConstraintsoptionalinterface{}#This parameter isn't supported for tasks run on AWS Fargate .
proxyConfigurationoptionalIResolvable | CfnTaskDefinition.ProxyConfigurationPropertyproxy_configurationoptionaltyping.Union[IResolvable, ProxyConfigurationProperty]proxyConfigurationoptionalIResolvableProxyConfigurationoptionalIResolvableProxyConfigurationoptionalinterface{}#notes
Your Amazon ECS container instances require at least version 1.26.0 of the container agent and at least version 1.26.0-1 of the ecs-init package to use a proxy configuration. If your container instances are launched from the Amazon ECS optimized AMI version 20190301 or later, they contain the required versions of the container agent and ecs-init . For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .
requiresCompatibilitiesoptionalstring[]requires_compatibilitiesoptionaltyping.List[str]requiresCompatibilitiesoptionalList<String>RequiresCompatibilitiesoptionalstring[]RequiresCompatibilitiesoptional*[]*string#notes
The valid values are MANAGED_INSTANCES , EC2 , FARGATE , and EXTERNAL . For more information, see Amazon ECS launch types in the Amazon Elastic Container Service Developer Guide .
runtimePlatformoptionalIResolvable | CfnTaskDefinition.RuntimePlatformPropertyruntime_platformoptionaltyping.Union[IResolvable, RuntimePlatformProperty]runtimePlatformoptionalIResolvableRuntimePlatformoptionalIResolvableRuntimePlatformoptionalinterface{}#tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag#notes
Each tag consists of a key and an optional value. You define both of them.
The following basic restrictions apply to tags:
- Maximum number of tags per resource - 50
- For each resource, each tag key must be unique, and each tag key can have only one value.
- Maximum key length - 128 Unicode characters in UTF-8
- Maximum value length - 256 Unicode characters in UTF-8
- If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : /
taskRoleArnoptionalstring | IRoleReftask_role_arnoptionaltyping.Union[str, IRoleRef]taskRoleArnoptionalStringTaskRoleArnoptionalstringTaskRoleArnoptionalinterface{}#notes
For more information, see Amazon ECS Task Role in the Amazon Elastic Container Service Developer Guide .
IAM roles for tasks on Windows require that the -EnableTaskIAMRole option is set when you launch the Amazon ECS-optimized Windows AMI. Your containers must also run some configuration code to use the feature. For more information, see Windows IAM roles for tasks in the Amazon Elastic Container Service Developer Guide .
String validation is done on the ECS side. If an invalid string value is given for
TaskRoleArn, it may cause the Cloudformation job to hang.
volumesoptionalIResolvable | IResolvable | CfnTaskDefinition.VolumeProperty[]volumesoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, VolumeProperty]]]volumesoptionalIResolvableVolumesoptionalIResolvableVolumesoptionalinterface{}#notes
For more information, see Using data volumes in tasks in the Amazon Elastic Container Service Developer Guide .
The
hostandsourcePathparameters aren't supported for tasks run on AWS Fargate .
Properties
attrTaskDefinitionArnstringattr_task_definition_arnstrattrTaskDefinitionArnStringAttrTaskDefinitionArnstringAttrTaskDefinitionArn*string#CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringstatic#cfnOptionsICfnResourceOptionscfn_optionsICfnResourceOptionscfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptions#cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*string#containerDefinitionsmay be undefinedIResolvable | IResolvable | CfnTaskDefinition.ContainerDefinitionProperty[]container_definitionsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ContainerDefinitionProperty]]]containerDefinitionsmay be undefinedIResolvableContainerDefinitionsmay be undefinedIResolvableContainerDefinitionsmay be undefinedinterface{}#cpumay be undefinedstringcpumay be undefinedstrcpumay be undefinedStringCpumay be undefinedstringCpumay be undefined*string#creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*string#enableFaultInjectionmay be undefinedboolean | IResolvableenable_fault_injectionmay be undefinedtyping.Union[bool, IResolvable]enableFaultInjectionmay be undefinedBooleanEnableFaultInjectionmay be undefinedboolEnableFaultInjectionmay be undefinedinterface{}#ephemeralStoragemay be undefinedIResolvable | CfnTaskDefinition.EphemeralStoragePropertyephemeral_storagemay be undefinedtyping.Union[IResolvable, EphemeralStorageProperty]ephemeralStoragemay be undefinedIResolvableEphemeralStoragemay be undefinedIResolvableEphemeralStoragemay be undefinedinterface{}#executionRoleArnmay be undefinedstringexecution_role_arnmay be undefinedstrexecutionRoleArnmay be undefinedStringExecutionRoleArnmay be undefinedstringExecutionRoleArnmay be undefined*string#familymay be undefinedstringfamilymay be undefinedstrfamilymay be undefinedStringFamilymay be undefinedstringFamilymay be undefined*string#inferenceAcceleratorsmay be undefinedIResolvable | IResolvable | CfnTaskDefinition.InferenceAcceleratorProperty[]inference_acceleratorsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, InferenceAcceleratorProperty]]]inferenceAcceleratorsmay be undefinedIResolvableInferenceAcceleratorsmay be undefinedIResolvableInferenceAcceleratorsmay be undefinedinterface{}deprecated#ipcModemay be undefinedstringipc_modemay be undefinedstripcModemay be undefinedStringIpcModemay be undefinedstringIpcModemay be undefined*string#The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use overrideLogicalId(newLogicalId).
memorymay be undefinedstringmemorymay be undefinedstrmemorymay be undefinedStringMemorymay be undefinedstringMemorymay be undefined*string#networkModemay be undefinedstringnetwork_modemay be undefinedstrnetworkModemay be undefinedStringNetworkModemay be undefinedstringNetworkModemay be undefined*string#pidModemay be undefinedstringpid_modemay be undefinedstrpidModemay be undefinedStringPidModemay be undefinedstringPidModemay be undefined*string#placementConstraintsmay be undefinedIResolvable | IResolvable | CfnTaskDefinition.TaskDefinitionPlacementConstraintProperty[]placement_constraintsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, TaskDefinitionPlacementConstraintProperty]]]placementConstraintsmay be undefinedIResolvablePlacementConstraintsmay be undefinedIResolvablePlacementConstraintsmay be undefinedinterface{}#proxyConfigurationmay be undefinedIResolvable | CfnTaskDefinition.ProxyConfigurationPropertyproxy_configurationmay be undefinedtyping.Union[IResolvable, ProxyConfigurationProperty]proxyConfigurationmay be undefinedIResolvableProxyConfigurationmay be undefinedIResolvableProxyConfigurationmay be undefinedinterface{}#If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).
requiresCompatibilitiesmay be undefinedstring[]requires_compatibilitiesmay be undefinedtyping.List[str]requiresCompatibilitiesmay be undefinedList<String>RequiresCompatibilitiesmay be undefinedstring[]RequiresCompatibilitiesmay be undefined*[]*string#runtimePlatformmay be undefinedIResolvable | CfnTaskDefinition.RuntimePlatformPropertyruntime_platformmay be undefinedtyping.Union[IResolvable, RuntimePlatformProperty]runtimePlatformmay be undefinedIResolvableRuntimePlatformmay be undefinedIResolvableRuntimePlatformmay be undefinedinterface{}#CfnElements must be defined within a stack scope (directly or indirectly).
tagsRawmay be undefinedCfnTag[]tags_rawmay be undefinedtyping.List[CfnTag]tagsRawmay be undefinedList<CfnTag>TagsRawmay be undefinedCfnTag[]TagsRawmay be undefined*[]CfnTag#taskDefinitionRefTaskDefinitionReferencetask_definition_refTaskDefinitionReferencetaskDefinitionRefTaskDefinitionReferenceTaskDefinitionRefTaskDefinitionReferenceTaskDefinitionRefTaskDefinitionReference#taskRoleArnmay be undefinedstringtask_role_arnmay be undefinedstrtaskRoleArnmay be undefinedStringTaskRoleArnmay be undefinedstringTaskRoleArnmay be undefined*string#volumesmay be undefinedIResolvable | IResolvable | CfnTaskDefinition.VolumeProperty[]volumesmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, VolumeProperty]]]volumesmay be undefinedIResolvableVolumesmay be undefinedIResolvableVolumesmay be undefinedinterface{}#Methods
addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#1 parameter
Parameters
pathpathpathpathPath— The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.
addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.
addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#notes · 2 parameters
To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.
For example,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"Properties": {
"GlobalSecondaryIndexes": [
{
"Projection": {
"NonKeyAttributes": [ "myattribute" ]
...
}
...
},
{
"ProjectionType": "INCLUDE"
...
},
]
...
}
The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.
Parameters
pathpathpathpathPath— - The path of the property, you can use dot notation to override values in complex types.valuevaluevaluevalueValue— - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#1 parameter
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#Syntactic sugar for addOverride("Properties.<...>", value).
2 parameters
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path of the property.valuevaluevaluevalueValue— The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.
1 parameter
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:
arnForTaskDefinition(resource: ITaskDefinitionRef): string@staticmethod def arn_for_task_definition(resource: ITaskDefinitionRef) -> strpublic static String arnForTaskDefinition(ITaskDefinitionRef resource)public static string ArnForTaskDefinition(ITaskDefinitionRef resource)func ArnForTaskDefinition(Resource ITaskDefinitionRef) *stringstatic#cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.
1 parameter
Parameters
attributeNameattribute_nameattributeNameattributeNameAttributeName— The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#1 parameter
Parameters
inspectorinspectorinspectorinspectorInspector— tree inspector to collect and process attributes.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.
returns
Returns: The construct as a stack element or undefined if it is not a stack element.
isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#isCfnTaskDefinition(x: any): boolean@staticmethod def is_cfn_task_definition(x: Any) -> boolpublic static Boolean isCfnTaskDefinition(Object x)public static bool IsCfnTaskDefinition(object x)func IsCfnTaskDefinition(X interface{}) *boolstatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.
overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#1 parameter
Parameters
newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId— The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#2 parameters
Parameters
targettargettargettargetTarget— The dependency to replace.newTargetnew_targetnewTargetnewTargetNewTarget— The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#returns
Returns: a string representation of this resource
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.