EcsTaskProps

class aws_cdk.aws_events_targets.EcsTaskProps(*, dead_letter_queue=None, max_event_age=None, retry_attempts=None, 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)

Bases: TargetBaseProps

Properties to define an ECS Event Task.

Parameters:
  • dead_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 queue

  • max_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

  • 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 false

  • container_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: - false

  • launch_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’ if isEc2Compatible for the taskDefinition 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 propagated

  • role (Optional[IRole]) – Existing IAM role to run the ECS task. Default: A new IAM role is created

  • security_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 created

  • subnet_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 subnets

  • tags (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 task

  • task_count (Union[int, float, None]) – How many tasks should be started when this event is triggered. Default: 1

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)
    ))

Attributes

assign_public_ip

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 false

cluster

Cluster where service will be deployed.

container_overrides

Container setting overrides.

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

dead_letter_queue

//docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html#dlq-considerations>`_.

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 queue

Type:

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

enable_execute_command

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:
  • false

launch_type

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’ if isEc2Compatible for the taskDefinition is true, otherwise ‘FARGATE’

max_event_age

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)

platform_version

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’

See:

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

propagate_tags

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 propagated

retry_attempts

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

Minimum value of 0. Maximum value of 185.

Default:

185

role

Existing IAM role to run the ECS task.

Default:

A new IAM role is created

security_groups

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

subnet_selection

In what subnets to place the task’s ENIs.

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

Default:

Private subnets

tags

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 task

task_count

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

Default:

1

task_definition

Task Definition of the task that should be started.