0

目标:使用Cloud Custodian,我希望 EC2 实例在每周一早上 CST 早上 7 点停止,并在每周日晚上 11 点开始。(此 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
4

1 回答 1

0

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

于 2019-09-12T18:39:11.913 回答