EcsTask
- class aws_cdk.aws_events_targets.EcsTask(*, cluster, task_definition, assign_public_ip=None, container_overrides=None, enable_execute_command=None, launch_type=None, platform_version=None, propagate_tags=None, role=None, security_groups=None, subnet_selection=None, tags=None, task_count=None, dead_letter_queue=None, max_event_age=None, retry_attempts=None)
Bases:
object
Start a task on an ECS cluster.
- ExampleMetadata:
infused
Example:
import aws_cdk.aws_ecs as ecs import aws_cdk.aws_ec2 as ec2 # cluster: ecs.ICluster # task_definition: ecs.TaskDefinition rule = events.Rule(self, "Rule", schedule=events.Schedule.rate(cdk.Duration.hours(1)) ) rule.add_target( targets.EcsTask( cluster=cluster, task_definition=task_definition, assign_public_ip=True, subnet_selection=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PUBLIC) ))
- Parameters:
cluster (
ICluster
) – Cluster where service will be deployed.task_definition (
ITaskDefinition
) – Task Definition of the task that should be started.assign_public_ip (
Optional
[bool
]) – Specifies whether the task’s elastic network interface receives a public IP address. You can specify true only when LaunchType is set to FARGATE. Default: - true if the subnet type is PUBLIC, otherwise falsecontainer_overrides (
Optional
[Sequence
[Union
[ContainerOverride
,Dict
[str
,Any
]]]]) – Container setting overrides. Key is the name of the container to override, value is the values you want to override.enable_execute_command (
Optional
[bool
]) – 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. Default: - falselaunch_type (
Optional
[LaunchType
]) – Specifies the launch type on which your task is running. The launch type that you specify here must match one of the launch type (compatibilities) of the target task. Default: - ‘EC2’ ifisEc2Compatible
for thetaskDefinition
is true, otherwise ‘FARGATE’platform_version (
Optional
[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’propagate_tags (
Optional
[PropagatedTagSource
]) – Specifies whether to propagate the tags from the task definition to the task. If no value is specified, the tags are not propagated. Default: - Tags will not be propagatedrole (
Optional
[IRole
]) – Existing IAM role to run the ECS task. Default: A new IAM role is createdsecurity_groups (
Optional
[Sequence
[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 createdsubnet_selection (
Union
[SubnetSelection
,Dict
[str
,Any
],None
]) – In what subnets to place the task’s ENIs. (Only applicable in case the TaskDefinition is configured for AwsVpc networking) Default: Private subnetstags (
Optional
[Sequence
[Union
[Tag
,Dict
[str
,Any
]]]]) – 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. Default: - No additional tags are applied to the tasktask_count (
Union
[int
,float
,None
]) – How many tasks should be started when this event is triggered. Default: 1dead_letter_queue (
Optional
[IQueue
]) – 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. Default: - no dead-letter queuemax_event_age (
Optional
[Duration
]) – The maximum age of a request that Lambda sends to a function for processing. Minimum value of 60. Maximum value of 86400. Default: Duration.hours(24)retry_attempts (
Union
[int
,float
,None
]) – The maximum number of times to retry when the function returns an error. Minimum value of 0. Maximum value of 185. Default: 185
Methods
- bind(_rule, _id=None)
Allows using tasks as target of EventBridge events.
- Parameters:
_rule (
IRule
) –_id (
Optional
[str
]) –
- Return type:
Attributes
- security_groups
The security groups associated with the task.
Only applicable with awsvpc network mode.
- Default:
A new security group is created.