aws-cdk-lib.aws_events_targets.EcsTaskProps

interface EcsTaskProps

LanguageType name
.NETAmazon.CDK.AWS.Events.Targets.EcsTaskProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awseventstargets#EcsTaskProps
Javasoftware.amazon.awscdk.services.events.targets.EcsTaskProps
Pythonaws_cdk.aws_events_targets.EcsTaskProps
TypeScript (source)aws-cdk-lib » aws_events_targets » EcsTaskProps

Properties to define an ECS Event Task.

Example

import * as ecs from "aws-cdk-lib/aws-ecs"
declare const cluster: ecs.ICluster
declare const taskDefinition: ecs.TaskDefinition

const rule = new events.Rule(this, 'Rule', {
  schedule: events.Schedule.rate(cdk.Duration.hours(1)),
});

rule.addTarget(new targets.EcsTask({
  cluster,
  taskDefinition,
  taskCount: 1,
  containerOverrides: [{
    containerName: 'TheContainer',
    command: ['echo', events.EventField.fromPath('$.detail.event')],
  }],
  enableExecuteCommand: true,
}));

Properties

NameTypeDescription
clusterIClusterCluster where service will be deployed.
taskDefinitionITaskDefinitionTask Definition of the task that should be started.
assignPublicIp?booleanSpecifies whether the task's elastic network interface receives a public IP address.
containerOverrides?ContainerOverride[]Container setting overrides.
deadLetterQueue?IQueueThe SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue.
enableExecuteCommand?booleanWhether or not to enable the execute command functionality for the containers in this task.
maxEventAge?DurationThe maximum age of a request that Lambda sends to a function for processing.
platformVersion?FargatePlatformVersionThe platform version on which to run your task.
propagateTags?PropagatedTagSourceSpecifies whether to propagate the tags from the task definition to the task.
retryAttempts?numberThe maximum number of times to retry when the function returns an error.
role?IRoleExisting IAM role to run the ECS task.
securityGroups?ISecurityGroup[]Existing security groups to use for the task's ENIs.
subnetSelection?SubnetSelectionIn what subnets to place the task's ENIs.
tags?Tag[]The metadata that you apply to the task to help you categorize and organize them.
taskCount?numberHow many tasks should be started when this event is triggered.

cluster

Type: ICluster

Cluster where service will be deployed.


taskDefinition

Type: ITaskDefinition

Task Definition of the task that should be started.


assignPublicIp?

Type: boolean (optional, default: true if the subnet type is PUBLIC, otherwise false)

Specifies whether the task's elastic network interface receives a public IP address.

You can specify true only when LaunchType is set to FARGATE.


containerOverrides?

Type: ContainerOverride[] (optional)

Container setting overrides.

Key is the name of the container to override, value is the values you want to override.


deadLetterQueue?

Type: IQueue (optional, default: no dead-letter queue)

The SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue.

The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.


enableExecuteCommand?

Type: boolean (optional, default: false)

Whether or not to enable the execute command functionality for the containers in this task.

If true, this enables execute command functionality on all containers in the task.


maxEventAge?

Type: Duration (optional, default: Duration.hours(24))

The maximum age of a request that Lambda sends to a function for processing.

Minimum value of 60. Maximum value of 86400.


platformVersion?

Type: FargatePlatformVersion (optional, default: ECS will set the Fargate platform version to 'LATEST')

The platform version on which to run your task.

Unless you have specific compatibility requirements, you don't need to specify this.

See also: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html


propagateTags?

Type: PropagatedTagSource (optional, default: Tags will not be propagated)

Specifies whether to propagate the tags from the task definition to the task.

If no value is specified, the tags are not propagated.


retryAttempts?

Type: number (optional, default: 185)

The maximum number of times to retry when the function returns an error.

Minimum value of 0. Maximum value of 185.


role?

Type: IRole (optional, default: A new IAM role is created)

Existing IAM role to run the ECS task.


securityGroups?

Type: ISecurityGroup[] (optional, default: A new security group is created)

Existing security groups to use for the task's ENIs.

(Only applicable in case the TaskDefinition is configured for AwsVpc networking)


subnetSelection?

Type: SubnetSelection (optional, default: Private subnets)

In what subnets to place the task's ENIs.

(Only applicable in case the TaskDefinition is configured for AwsVpc networking)


tags?

Type: Tag[] (optional, default: No additional tags are applied to the task)

The metadata that you apply to the task to help you categorize and organize them.

Each tag consists of a key and an optional value, both of which you define.


taskCount?

Type: number (optional, default: 1)

How many tasks should be started when this event is triggered.