云托管下班时间政策

时间:2019-02-13 21:04:37

标签: amazon-web-services amazon-ec2 aws-lambda

目标:使用Cloud Custodian,我希望EC2实例在每个星期一早上7点CST停止并在每个星期日晚上11点CST开始。 (此EC2实例将在每个星期一运行8个小时以执行特定任务,并且剩余时间应保持关闭状态)。这将是选择加入的政策

有人可以在下面查看我的书面政策。我正在尝试使用基于标签的配置来实现这一目标。不知道怎么办?

- name: ec2-off-hours-stop
  resource: ec2
  comments: |
    Stop EC2 instances, every monday morning at 7:00 AM (CST)
  filters:
    - type: offhour
      default_tz: ct
      tag: c7n_maid_offhours
      opt-out: false
      offhour: 7    (How do I mention Monday? off=M,7)
  mode:
      schedule: "rate(60 minutes)"
      type: periodic
      execution-options:
        output_dir: s3://abcdreports/abcdLogs/{account_id}/
  actions:
    - stop

- name: ec2-off-hours-start
  resource: ec2
  comments: |
    Start EC2 instances, every sunday night at 11:00 PM (CST)
  filters:
    - type: onhour
      default_tz: ct
      tag: c7n_maid_offhours
      opt-out: false
      onhour: 23 (How do I mention Sunday? on=U,23)
  mode:
      schedule: "rate(60 minutes)"
      type: periodic
      execution-options:
        output_dir: s3://abcdreports/abcdLogs/{account_id}/
  actions:
    - start

1 个答案:

答案 0 :(得分:0)

带有“ off =(M,7); on =(S,18)”的标签值可以做到这一点,我们不支持仅在周末规范之外的操作中的日配置。您也许可以使用值过滤器来比较当前日期。如果有兴趣,请提出问题。