# EcsRunTaskBaseProps

Parameters for scheduling ECS Run Task (common to EC2 and Fargate launch types).

Extends: [ScheduleTargetBaseProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler_targets.ScheduleTargetBaseProps.html)
Used as props by: [EcsRunTask](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler_targets.EcsRunTask.html)

- Source: [`aws-scheduler-targets/lib/ecs-run-task.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-scheduler-targets/lib/ecs-run-task.ts#L28)
- Type last changed: v2.186.0 · 27 Mar 2025

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
import { aws_scheduler as scheduler } from 'aws-cdk-lib';
import { aws_scheduler_targets as scheduler_targets } from 'aws-cdk-lib';
import { aws_sqs as sqs } from 'aws-cdk-lib';

declare const queue: sqs.Queue;
declare const role: iam.Role;
declare const scheduleTargetInput: scheduler.ScheduleTargetInput;
declare const securityGroup: ec2.SecurityGroup;
declare const subnet: ec2.Subnet;
declare const subnetFilter: ec2.SubnetFilter;
declare const taskDefinition: ecs.TaskDefinition;
const ecsRunTaskBaseProps: scheduler_targets.EcsRunTaskBaseProps = {
  taskDefinition: taskDefinition,

  // the properties below are optional
  capacityProviderStrategies: [{
    capacityProvider: 'capacityProvider',

    // the properties below are optional
    base: 123,
    weight: 123,
  }],
  deadLetterQueue: queue,
  enableEcsManagedTags: false,
  enableExecuteCommand: false,
  group: 'group',
  input: scheduleTargetInput,
  maxEventAge: cdk.Duration.minutes(30),
  propagateTags: false,
  referenceId: 'referenceId',
  retryAttempts: 123,
  role: role,
  securityGroups: [securityGroup],
  tags: [{
    key: 'key',
    value: 'value',
  }],
  taskCount: 123,
  vpcSubnets: {
    availabilityZones: ['availabilityZones'],
    onePerAz: false,
    subnetFilters: [subnetFilter],
    subnetGroupName: 'subnetGroupName',
    subnets: [subnet],
    subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
  },
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_ec2 as ec2
from aws_cdk import aws_ecs as ecs
from aws_cdk import aws_iam as iam
from aws_cdk import aws_scheduler as scheduler
from aws_cdk import aws_scheduler_targets as scheduler_targets
from aws_cdk import aws_sqs as sqs

# queue: sqs.Queue
# role: iam.Role
# schedule_target_input: scheduler.ScheduleTargetInput
# security_group: ec2.SecurityGroup
# subnet: ec2.Subnet
# subnet_filter: ec2.SubnetFilter
# task_definition: ecs.TaskDefinition

ecs_run_task_base_props = scheduler_targets.EcsRunTaskBaseProps(
    task_definition=task_definition,

    # the properties below are optional
    capacity_provider_strategies=[ecs.CapacityProviderStrategy(
        capacity_provider="capacityProvider",

        # the properties below are optional
        base=123,
        weight=123
    )],
    dead_letter_queue=queue,
    enable_ecs_managed_tags=False,
    enable_execute_command=False,
    group="group",
    input=schedule_target_input,
    max_event_age=cdk.Duration.minutes(30),
    propagate_tags=False,
    reference_id="referenceId",
    retry_attempts=123,
    role=role,
    security_groups=[security_group],
    tags=[scheduler_targets.Tag(
        key="key",
        value="value"
    )],
    task_count=123,
    vpc_subnets=ec2.SubnetSelection(
        availability_zones=["availabilityZones"],
        one_per_az=False,
        subnet_filters=[subnet_filter],
        subnet_group_name="subnetGroupName",
        subnets=[subnet],
        subnet_type=ec2.SubnetType.PRIVATE_ISOLATED
    )
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.ecs.*;
import software.amazon.awscdk.services.iam.*;
import software.amazon.awscdk.services.scheduler.*;
import software.amazon.awscdk.services.scheduler.targets.*;
import software.amazon.awscdk.services.sqs.*;

Queue queue;
Role role;
ScheduleTargetInput scheduleTargetInput;
SecurityGroup securityGroup;
Subnet subnet;
SubnetFilter subnetFilter;
TaskDefinition taskDefinition;

EcsRunTaskBaseProps ecsRunTaskBaseProps = EcsRunTaskBaseProps.builder()
        .taskDefinition(taskDefinition)

        // the properties below are optional
        .capacityProviderStrategies(List.of(CapacityProviderStrategy.builder()
                .capacityProvider("capacityProvider")

                // the properties below are optional
                .base(123)
                .weight(123)
                .build()))
        .deadLetterQueue(queue)
        .enableEcsManagedTags(false)
        .enableExecuteCommand(false)
        .group("group")
        .input(scheduleTargetInput)
        .maxEventAge(Duration.minutes(30))
        .propagateTags(false)
        .referenceId("referenceId")
        .retryAttempts(123)
        .role(role)
        .securityGroups(List.of(securityGroup))
        .tags(List.of(Tag.builder()
                .key("key")
                .value("value")
                .build()))
        .taskCount(123)
        .vpcSubnets(SubnetSelection.builder()
                .availabilityZones(List.of("availabilityZones"))
                .onePerAz(false)
                .subnetFilters(List.of(subnetFilter))
                .subnetGroupName("subnetGroupName")
                .subnets(List.of(subnet))
                .subnetType(SubnetType.PRIVATE_ISOLATED)
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.IAM;
using Amazon.CDK.AWS.Scheduler;
using Amazon.CDK.AWS.Scheduler.Targets;
using Amazon.CDK.AWS.SQS;

Queue queue;
Role role;
ScheduleTargetInput scheduleTargetInput;
SecurityGroup securityGroup;
Subnet subnet;
SubnetFilter subnetFilter;
TaskDefinition taskDefinition;

var ecsRunTaskBaseProps = new EcsRunTaskBaseProps {
    TaskDefinition = taskDefinition,

    // the properties below are optional
    CapacityProviderStrategies = new [] { new CapacityProviderStrategy {
        CapacityProvider = "capacityProvider",

        // the properties below are optional
        Base = 123,
        Weight = 123
    } },
    DeadLetterQueue = queue,
    EnableEcsManagedTags = false,
    EnableExecuteCommand = false,
    Group = "group",
    Input = scheduleTargetInput,
    MaxEventAge = Duration.Minutes(30),
    PropagateTags = false,
    ReferenceId = "referenceId",
    RetryAttempts = 123,
    Role = role,
    SecurityGroups = new [] { securityGroup },
    Tags = new [] { new Tag {
        Key = "key",
        Value = "value"
    } },
    TaskCount = 123,
    VpcSubnets = new SubnetSelection {
        AvailabilityZones = new [] { "availabilityZones" },
        OnePerAz = false,
        SubnetFilters = new [] { subnetFilter },
        SubnetGroupName = "subnetGroupName",
        Subnets = new [] { subnet },
        SubnetType = SubnetType.PRIVATE_ISOLATED
    }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var queue Queue
var role Role
var scheduleTargetInput ScheduleTargetInput
var securityGroup SecurityGroup
var subnet Subnet
var subnetFilter SubnetFilter
var taskDefinition TaskDefinition

ecsRunTaskBaseProps := &EcsRunTaskBaseProps{
	TaskDefinition: taskDefinition,

	// the properties below are optional
	CapacityProviderStrategies: []CapacityProviderStrategy{
		&CapacityProviderStrategy{
			CapacityProvider: jsii.String("capacityProvider"),

			// the properties below are optional
			Base: jsii.Number(123),
			Weight: jsii.Number(123),
		},
	},
	DeadLetterQueue: queue,
	EnableEcsManagedTags: jsii.Boolean(false),
	EnableExecuteCommand: jsii.Boolean(false),
	Group: jsii.String("group"),
	Input: scheduleTargetInput,
	MaxEventAge: cdk.Duration_Minutes(jsii.Number(30)),
	PropagateTags: jsii.Boolean(false),
	ReferenceId: jsii.String("referenceId"),
	RetryAttempts: jsii.Number(123),
	Role: role,
	SecurityGroups: []ISecurityGroup{
		securityGroup,
	},
	Tags: []Tag{
		&Tag{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
	TaskCount: jsii.Number(123),
	VpcSubnets: &SubnetSelection{
		AvailabilityZones: []*string{
			jsii.String("availabilityZones"),
		},
		OnePerAz: jsii.Boolean(false),
		SubnetFilters: []SubnetFilter{
			subnetFilter,
		},
		SubnetGroupName: jsii.String("subnetGroupName"),
		Subnets: []ISubnet{
			subnet,
		},
		SubnetType: awscdk.Aws_ec2.SubnetType_PRIVATE_ISOLATED,
	},
}
```

## Properties

- `capacityProviderStrategies`: [CapacityProviderStrategy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.CapacityProviderStrategy.html)[] — The capacity provider strategy to use for the task.

  **Default:** No capacity provider strategy

- `deadLetterQueue`: [IQueue](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.IQueue.html) — The SQS queue to be used as deadLetterQueue.

  **Default:** no 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.

- `enableEcsManagedTags`: boolean = false — Specifies whether to enable Amazon ECS managed tags for the task.

- `enableExecuteCommand`: boolean = false — Whether to enable execute command functionality for the containers in this task.

  If true, this enables execute command functionality on all containers in the task.

- `group`: string — Specifies an ECS task group for the task.

  **Default:** No group

- `input`: [ScheduleTargetInput](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.ScheduleTargetInput.html) — Input passed to the target.

  **Default:** no input.

- `maxEventAge`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.hours(24) — The maximum age of a request that Scheduler sends to a target for processing.

  Minimum value of 60.
  Maximum value of 86400.

- `propagateTags`: boolean — Specifies whether to propagate the tags from the task definition to the task.

  **Default:** No tag propagation

  If no value is specified, the tags are not propagated.

- `referenceId`: string — The reference ID to use for the task.

  **Default:** No reference ID.

- `retryAttempts`: number = 185 — The maximum number of times to retry when the target returns an error.

  Minimum value of 0.
  Maximum value of 185.

- `role`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — An execution role is an IAM role that EventBridge Scheduler assumes in order to interact with other AWS services on your behalf.

  **Default:** created by target

  If none provided templates target will automatically create an IAM role with all the minimum necessary
  permissions to interact with the templated target. If you wish you may specify your own IAM role, then the templated targets
  will grant minimal required permissions.

- `securityGroups`: [ISecurityGroup](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — The security groups associated with the task.

  **Default:** The security group for the VPC is used.

  These security groups must all be in the same VPC.
  Controls inbound and outbound network access for the task.

- `tags`: [Tag](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler_targets.Tag.html)[] — The metadata that you apply to the task to help you categorize and organize them.

  **Default:** No tags

  Each tag consists of a key and an optional value, both of which you define.

- `taskCount`: number = 1 — The number of tasks to create based on TaskDefinition.

- `taskDefinition`: [TaskDefinition](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.TaskDefinition.html) (required) — The task definition to use for scheduled tasks.

  Note: this must be TaskDefinition, and not ITaskDefinition,
  as it requires properties that are not known for imported task definitions
  If you want to run a RunTask with an imported task definition,
  consider using a Universal target.

- `vpcSubnets`: [SubnetSelection](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — The subnets associated with the task.

  **Default:** all private subnets of the VPC are selected.

  These subnets must all be in the same VPC.
  The task will be launched in these subnets.
