Переопределение контейнера AWS Cloudformation - PullRequest
0 голосов
/ 26 июня 2018

Я создал taskDefinition с использованием облачной информации, а в ContainerDefinitions У меня есть Command для запуска приложения с daily в качестве параметра.

TaskDefinition: 
  Type: AWS::ECS::TaskDefinition
  Properties:
    :
    :
    ContainerDefinitions:
    - Name: test-report
      :
      :
      Command:
      - "./test_report"
      - daily

И я хочу создатьTaskSchedule для различной частоты (например, ежедневно, еженедельно, ежемесячно и т. Д.).

Я знаю, что в консоли AWS я могу перейти на Edit Scheduled Task> Schedule Targets> Container override и обновить command override with ./test_report, weekly.

Но как переопределить команду в cloudform taskSchedule?Это что-то делать в Targets собственности ??

  TaskSchedule:
    Type: AWS::Events::Rule
    Properties:
      :
      Targets:

Заранее спасибо

1 Ответ

0 голосов
/ 26 июня 2018

В шаблоне cloudformation расписание правила события CloudWatch определяется с помощью выражений cron (или, альтернативно, выражений скорости).Вы не можете переопределить точку входа из самого правила, но вы можете создать определение задачи для каждого из типов отчетов (частот).Мне не удалось найти переопределение команды задачи в пользовательском интерфейсе или в документации по облачной информации.

TaskDefinitionDaily: 
  Type: AWS::ECS::TaskDefinition
  Properties:
     # other task definition elements here
     ContainerDefinitions:
       # other container definitions here
        Command: 
          - "./test_report"
          - daily

TaskDefinitionWeekly: 
  Type: AWS::ECS::TaskDefinition
  Properties:
     # other task definition elements here
     ContainerDefinitions:
       # other container definitions here
        Command: 
          - "./test_report"
          - weekly

TaskDefinitionMonthly: 
  Type: AWS::ECS::TaskDefinition
  Properties:
     # other task definition elements here
     ContainerDefinitions:
       # other container definitions here
        Command: 
          - "./test_report"
          - monthly


# daily schedule at midnight UTC      
ScheduledRuleDaily: 
  Type: "AWS::Events::Rule"
  Properties: 
    Description: "ScheduledRule"
    ScheduleExpression: "cron(00 00 * * ? *)"
    State: "ENABLED"
    Targets:
          - Arn: !GetAtt 
              - MyCluster
              - Arn
            RoleArn: !GetAtt 
              - ECSTaskRole
              - Arn
            Id: id1
            EcsParameters:
              TaskCount: 1
              TaskDefinitionArn: !Ref TaskDefinitionDaily


# weekly schedule at midnight UTC   
ScheduledRuleWeekly: 
  Type: "AWS::Events::Rule"
  Properties: 
    Description: "ScheduledRule"
    ScheduleExpression: "cron(00 00 ? * 1 *)"
    State: "ENABLED"
    Targets:
          - Arn: !GetAtt 
              - MyCluster
              - Arn
            RoleArn: !GetAtt 
              - ECSTaskRole
              - Arn
            Id: id1
            EcsParameters:
              TaskCount: 1
              TaskDefinitionArn: !Ref TaskDefinitionWeekly

# monthly schedule  at midnight UTC     
ScheduledRuleMonthly: 
  Type: "AWS::Events::Rule"
  Properties: 
    Description: "ScheduledRule"
    ScheduleExpression: "cron(00 00 1 * ? *)"
    State: "ENABLED"
    Targets:
          - Arn: !GetAtt 
              - MyCluster
              - Arn
            RoleArn: !GetAtt 
              - ECSTaskRole
              - Arn
            Id: id1
            EcsParameters:
              TaskCount: 1
              TaskDefinitionArn: !Ref TaskDefinitionMonthly

Подробнее о выражениях правил событий можно прочитать на веб-сайте документации amazon .

...