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, cpu=None, enable_execute_command=None, ephemeral_storage=None, execution_role=None, inference_accelerator_overrides=None, launch_type=None, memory=None, platform_version=None, propagate_tags=None, role=None, security_groups=None, subnet_selection=None, tags=None, task_count=None, task_role=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.

  • cpu (Optional[str]) – The CPU override for the task. Default: - The task definition’s CPU value

  • 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

  • ephemeral_storage (Union[EphemeralStorageOverride, Dict[str, Any], None]) – The ephemeral storage setting override for the task. NOTE: This parameter is only supported for tasks hosted on Fargate that use the following platform versions: - Linux platform version 1.4.0 or later. - Windows platform version 1.0.0 or later. Default: - The task definition’s ephemeral storage value

  • execution_role (Optional[IRole]) – The execution role for the task. The Amazon Resource Name (ARN) of the task execution role override for the task. Default: - The task definition’s execution role

  • inference_accelerator_overrides (Optional[Sequence[Union[InferenceAcceleratorOverride, Dict[str, Any]]]]) – The Elastic Inference accelerator override for the task. Default: - The task definition’s inference accelerator overrides

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

  • memory (Optional[str]) – The memory override for the task. Default: - The task definition’s memory value

  • 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

  • task_role (Optional[IRole]) – The IAM role for the task. Default: - The task definition’s task role

ExampleMetadata:

infused

Example:

import aws_cdk.aws_ecs as ecs

# 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,
    task_count=1,

    # Overrides the cpu and memory values in the task definition
    cpu="512",
    memory="512"
))

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.

cpu

The CPU override for the task.

Default:
  • The task definition’s CPU value

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

ephemeral_storage

The ephemeral storage setting override for the task.

NOTE: This parameter is only supported for tasks hosted on Fargate that use the following platform versions:

  • Linux platform version 1.4.0 or later.

  • Windows platform version 1.0.0 or later.

Default:
  • The task definition’s ephemeral storage value

execution_role

The execution role for the task.

The Amazon Resource Name (ARN) of the task execution role override for the task.

Default:
  • The task definition’s execution role

inference_accelerator_overrides

The Elastic Inference accelerator override for the task.

Default:
  • The task definition’s inference accelerator overrides

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)

memory

The memory override for the task.

Default:
  • The task definition’s memory value

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.

task_role

The IAM role for the task.

Default:
  • The task definition’s task role