EcsTask(*, cluster, task_definition, container_overrides=None, platform_version=None, role=None, security_group=None, security_groups=None, subnet_selection=None, task_count=None)¶
Start a task on an ECS cluster.
from aws_cdk.aws_events import Rule, Schedule from aws_cdk.aws_events_targets import EcsTask from aws_cdk.aws_ecs import Cluster, TaskDefinition from aws_cdk.aws_iam import Role # cluster is of type Cluster # task_definition is of type TaskDefinition # role is of type Role ecs_task_target = EcsTask(cluster=cluster, task_definition=task_definition, role=role) Rule(self, "ScheduleRule", schedule=Schedule.cron(minute="0", hour="4"), targets=[ecs_task_target] )
ICluster) – Cluster where service will be deployed.
ITaskDefinition) – Task Definition of the task that should be started.
ContainerOverride]]) – Container setting overrides. Key is the name of the container to override, value is the values you want to override.
FargatePlatformVersion]) – The platform version on which to run your task. Unless you have specific compatibility requirements, you don’t need to specify this. Default: - ECS will set the Fargate platform version to ‘LATEST’
IRole]) – Existing IAM role to run the ECS task. Default: A new IAM role is created
ISecurityGroup]) – (deprecated) Existing security group to use for the task’s ENIs. (Only applicable in case the TaskDefinition is configured for AwsVpc networking) Default: A new security group is created
ISecurityGroup]]) – Existing security groups to use for the task’s ENIs. (Only applicable in case the TaskDefinition is configured for AwsVpc networking) Default: A new security group is created
SubnetSelection]) – In what subnets to place the task’s ENIs. (Only applicable in case the TaskDefinition is configured for AwsVpc networking) Default: Private subnets
None]) – How many tasks should be started when this event is triggered. Default: 1
Allows using tasks as target of EventBridge events.
(deprecated) The security group associated with the task.
Only applicable with awsvpc network mode.
A new security group is created.
use securityGroups instead.
- Return type