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';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
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,
assignPublicIp: true,
subnetSelection: { subnetType: ec2.SubnetType.PUBLIC },
}),
);
Initializer
new EcsTask(props: EcsTaskProps)
Parameters
- props
Ecs
Task 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.