AWS ECS通过Cloudformation创建计划任务(cron) [英] AWS ECS Create Scheduled Tasks (cron) via Cloudformation

查看:174
本文介绍了AWS ECS通过Cloudformation创建计划任务(cron)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想通过CloudFormation在AWS ECS中创建 ScheduledTasks 。是否有编程方式通过boto或cloudformation创建?

We want to create ScheduledTasks in AWS ECS via CloudFormation. Is there a programmatic way to create via boto or cloudformation?

推荐答案

要在CloudFormation中定义计划的ECS任务,您需要定义一个以ECS任务为目标的 AWS :: Events :: Rule资源。

In order to define a scheduled ECS task in CloudFormation, you need to define a "AWS::Events::Rule" resource with an ECS task as a target.

"TaskSchedule": {
  "Type": "AWS::Events::Rule",
  "Properties": {
    "Description": "dump data every workday at 10",
    "Name": "dump-data",
    "ScheduleExpression": "cron(0 10 ? * MON-FRI *)",
    "State": "ENABLED",
    "Targets": [
      {
        "Id": "dump-data-ecs-task",
        "RoleArn": {
          "Fn::GetAtt": ["TaskSchedulerRole", "Arn"]
        },
        "EcsParameters": {
          "TaskDefinitionArn": {
            "Ref": "TaskDefinition"
          },
          "TaskCount": 1
        },
        "Arn": {
          "Fn::GetAtt": ["EcsCluster", "Arn"]
        }
      }
    ]
  }
}

这篇关于AWS ECS通过Cloudformation创建计划任务(cron)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆