Skip to content
v2.274.0

EcsRunFargateTask Class ​

Schedule an ECS Task on Fargate using AWS EventBridge Scheduler.

Example ​

ts
import * as ecs from 'aws-cdk-lib/aws-ecs';

declare const cluster: ecs.ICluster;
declare const taskDefinition: ecs.FargateTaskDefinition;

new Schedule(this, 'Schedule', {
  schedule: ScheduleExpression.rate(cdk.Duration.minutes(60)),
  target: new targets.EcsRunFargateTask(cluster, {
    taskDefinition,
  }),
});
python
import aws_cdk.aws_ecs as ecs

# cluster: ecs.ICluster
# task_definition: ecs.FargateTaskDefinition


Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(cdk.Duration.minutes(60)),
    target=targets.EcsRunFargateTask(cluster,
        task_definition=task_definition
    )
)
java
import software.amazon.awscdk.services.ecs.*;

ICluster cluster;
FargateTaskDefinition taskDefinition;


Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.minutes(60)))
        .target(EcsRunFargateTask.Builder.create(cluster)
                .taskDefinition(taskDefinition)
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.ECS;

ICluster cluster;
FargateTaskDefinition taskDefinition;


new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Minutes(60)),
    Target = new EcsRunFargateTask(cluster, new FargateTaskProps {
        TaskDefinition = taskDefinition
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import ecs "github.com/aws/aws-cdk-go/awscdk"

var cluster ICluster
var taskDefinition FargateTaskDefinition


awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(cdk.Duration_Minutes(jsii.Number(60))),
	Target: targets.NewEcsRunFargateTask(cluster, &FargateTaskProps{
		TaskDefinition: *TaskDefinition,
	}),
})

Initializer ​

ts
new EcsRunFargateTask(cluster: ICluster, props: FargateTaskProps)
python
EcsRunFargateTask(cluster: ICluster, props: FargateTaskProps)
java
new EcsRunFargateTask(ICluster cluster, FargateTaskProps props)
csharp
new EcsRunFargateTask(ICluster cluster, FargateTaskProps props)
go
NewEcsRunFargateTask(Cluster ICluster, Props FargateTaskProps)

Methods ​

bind(schedule: ISchedule): ScheduleTargetConfigdef bind(self, schedule: ISchedule) -> ScheduleTargetConfigpublic ScheduleTargetConfig bind(ISchedule schedule)public ScheduleTargetConfig Bind(ISchedule schedule)func Bind(Schedule ISchedule) ScheduleTargetConfig#
Create a return a Schedule Target Configuration for the given schedule.
returns

Returns: a Schedule Target Configuration