class EcsTask
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Events.Targets.EcsTask |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awseventstargets#EcsTask |
Java | software.amazon.awscdk.services.events.targets.EcsTask |
Python | aws_cdk.aws_events_targets.EcsTask |
TypeScript (source) | aws-cdk-lib » aws_events_targets » EcsTask |
Implements
IRule
Start a task on an ECS cluster.
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,
// Overrides the cpu and memory values in the task definition
cpu: '512',
memory: '512',
}));
Initializer
new EcsTask(props: EcsTaskProps)
Parameters
- props
EcsTask Props
Properties
| Name | Type | Description |
|---|---|---|
| security | ISecurity[] | The security groups associated with the task. |
securityGroups?
Type:
ISecurity[]
(optional, default: A new security group is created.)
The security groups associated with the task.
Only applicable with awsvpc network mode.
Methods
| Name | Description |
|---|---|
| bind(rule, _id?) | Allows using tasks as target of EventBridge events. |
bind(rule, _id?)
public bind(rule: IRule, _id?: string): RuleTargetConfig
Parameters
- rule
IRule - _id
string
Returns
Allows using tasks as target of EventBridge events.

.NET
Go
Java
Python
TypeScript (