全部产品
Search
文档中心

CloudOps Orchestration Service:ACS::Approve

更新时间:Jun 28, 2025

Tindakan ACS::Approve digunakan untuk menyetujui tugas.

Deskripsi

Selama operasi otomatis O&M, beberapa operasi harus dilakukan dengan hati-hati, seperti menghapus sumber daya penting atau membeli instance dengan biaya tinggi. Jika operasi ini dilakukan secara otomatis, Anda mungkin kehilangan kendali atas sumber daya Anda, atau batas anggaran mungkin terlampaui. Namun, jika tidak diotomatiskan, Anda perlu melakukannya secara manual atau menggunakan metode lain yang tidak otomatis. Tindakan ACS::Approve membantu Anda menemukan keseimbangan antara eksekusi otomatis dan operasi yang memerlukan perhatian khusus.

Ketika tindakan ACS::Approve digunakan dalam template, mesin eksekusi CloudOps Orchestration Service (OOS) akan menangguhkan eksekusi operasi berikutnya, mengatur status eksekusi menjadi Menunggu, dan mengirimkan notifikasi kepada administrator. Setelah menerima notifikasi sebagai administrator, Anda dapat memutuskan untuk menyetujui atau menolak operasi tersebut sesuai dengan kebutuhan bisnis. Jika disetujui, mesin eksekusi OOS akan melanjutkan operasi berikutnya. Jika ditolak, mesin eksekusi OOS akan menghentikan eksekusi dan mengatur status eksekusi menjadi Dibatalkan.

Sintaks Webhook

Anda dapat mengonfigurasi webhook untuk mengirim notifikasi ke klien, seperti DingTalk.

  • Format YAML

Tasks:
  - Name: approvalTask
    Action: ACS::Approve
    Properties:
      AppendExecutionLink: 'true' # Menentukan apakah akan menambahkan tautan eksekusi. Nilai valid: true dan false. Nilai default: true. 
      Approvers: ["user1", "user2", "user3"] # Nama pengguna Resource Access Management (RAM) yang bertindak sebagai pemberi persetujuan. 
      MinRequiredApprovals: 2 # Jumlah minimum pemberi persetujuan yang diperlukan untuk menyetujui tugas. 
      NotifyType: WebHook
      WebHook:
        URI: url # Wajib. URL webhook. Contoh: https://oapi.dingtalk.com/robot/send?access_token=xxxxxx.
        Headers: # Opsional. Header permintaan HTTP. Contoh: Content-Type.
          Content-Type: 'application/json; charset=utf-8'
        Content: # Wajib. Isi notifikasi webhook. Atur nilai berdasarkan persyaratan untuk webhook. Untuk informasi tentang isi webhook DingTalk, kunjungi https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1. 
          msgtype: text
          text:
            content: 'notifikasi persetujuan kepada pengguna' # Wajib. Isi notifikasi persetujuan. 
          at: # Pengguna yang di@ di grup DingTalk.
            atMobiles: # Opsional. Pengguna yang di@ di grup DingTalk. Tentukan pengguna menggunakan nomor ponsel yang mereka gunakan untuk membuat akun DingTalk mereka. 
                        - 138albb1234
                        - 130albb1234
            isAtAll: 'false' # Opsional. Menentukan apakah akan @ semua pengguna di grup DingTalk. Nilai valid: true dan false. Nilai default: false.
  • Format JSON (Untuk informasi lebih lanjut, lihat deskripsi atribut untuk format YAML.)

{
  "Tasks": [
    {
      "Name": "approvalTask",
      "Action": "ACS::Approve",
      "Properties": {
        "AppendExecutionLink": "true",
        "Approvers": [
          "user1",
          "user2",
          "user3"
        ],
        "MinRequiredApprovals": 2,
        "NotifyType": "WebHook",
        "WebHook": {
          "URI": "url",
          "Headers": {
            "Content-Type": "application/json; charset=utf-8"
          },
          "Content": {
            "msgtype": "text",
            "text": {
              "content": "notifikasi persetujuan kepada pengguna"
            },
            "at": {
              "atMobiles": [
                "138albb1234",
                "130albb1234"
              ],
              "isAtAll": "false"
            }
          }
        }
      }
    }
  ]
}

Contoh Webhook

Template berikut digunakan untuk menghapus instance Elastic Compute Service (ECS) setelah persetujuan.

  • Format YAML

---
FormatVersion: OOS-2019-06-01
Description:
  en: Bulky restarts the ECS instances with Approval.
   
  name-en: BulkyRebootInstancesWithApproval
   
Parameters:
  targets:
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
  rateControl:
    Description:
      en: Concurrency ratio of task execution.
       
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 100%
  webHookUrl:
    Description:
      en: >-
        The webHook url of dingtalk group assistant,
        e.g.https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414.
      zh-cn: >-
         
    Type: String
  atMobiles:
    Description:
      en: >-
        The telephone numbers of member in dingtalk group assistant @, when
        notify comes.
       
    Type: List
    Default:
      - '1390000****'
  atAll:
    Description:
      en: 'assistant @ all members in dingtalk group or not, when notify comes.'
       
    Type: String
    Default: 'false'
  OOSAssumeRole:
    Description:
      en: The RAM role to be assumed by OOS.
       
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances.
       
    Action: 'ACS::SelectTargets'
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceId'
      instanceNames:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceName'
  - Name: approveRestart
    Action: 'ACS::Approve'
    Properties:
      NotifyType: WebHook
      WebHook:
        URI: '{{webhookUrl}}'
        Headers:
          Content-Type: application/json
        Content:
          msgtype: text
          text:
            content: >-
              Notifikasi: harap setujui restart instance, nama instance untuk
              disetujui adalah {{getInstance.instanceNames}}, dikirim oleh
              {{ACS::RegionId}} oos {{ACS::ExecutionId}}.
          at:
            atMobiles: '{{atMobiles}}'
            isAtAll: '{{atAll}}'
  - Name: rebootInstance
    Action: 'ACS::ECS::RebootInstance'
    Description:
      en: Restarts the ECS instances.
       
    Properties:
      instanceId: '{{ ACS::TaskLoopItem }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
Outputs:
  instanceIds:
    Type: List
    Value: '{{ getInstance.instanceIds }}'
  • Format JSON

{
  "FormatVersion": "OOS-2019-06-01",
  "Description": {
    "en": "Bulky restarts the ECS instances with Approval.",
     
    "name-en": "BulkyRebootInstancesWithApproval",
     
  },
  "Parameters": {
    "targets": {
      "Type": "Json",
      "AssociationProperty": "Targets",
      "AssociationPropertyMetadata": {
        "ResourceType": "ALIYUN::ECS::Instance"
      }
    },
    "rateControl": {
      "Description": {
        "en": "Concurrency ratio of task execution.",
         
      },
      "Type": "Json",
      "AssociationProperty": "RateControl",
      "Default": {
        "Mode": "Concurrency",
        "MaxErrors": 0,
        "Concurrency": "100%"
      }
    },
    "webHookUrl": {
      "Description": {
        "en": "The webHook url of dingtalk group assistant, e.g.https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414.",
         
      },
      "Type": "String"
    },
    "atMobiles": {
      "Description": {
        "en": "The telephone numbers of member in dingtalk group assistant @, when notify comes.",
         
      },
      "Type": "List",
      "Default": [
        "1390000****"
      ]
    },
    "atAll": {
      "Description": {
        "en": "assistant @ all members in dingtalk group or not, when notify comes.",
         
      },
      "Type": "String",
      "Default": "false"
    },
    "OOSAssumeRole": {
      "Description": {
        "en": "The RAM role to be assumed by OOS.",
         
      },
      "Type": "String",
      "Default": "OOSServiceRole"
    }
  },
  "RamRole": "{{ OOSAssumeRole }}",
  "Tasks": [
    {
      "Name": "getInstance",
      "Description": {
        "en": "Views the ECS instances.",
         
      },
      "Action": "ACS::SelectTargets",
      "Properties": {
        "ResourceType": "ALIYUN::ECS::Instance",
        "Filters": [
          "{{ targets }}"
        ]
      },
      "Outputs": {
        "instanceIds": {
          "Type": "List",
          "ValueSelector": "Instances.Instance[].InstanceId"
        },
        "instanceNames": {
          "Type": "List",
          "ValueSelector": "Instances.Instance[].InstanceName"
        }
      }
    },
    {
      "Name": "approveRestart",
      "Action": "ACS::Approve",
      "Properties": {
        "NotifyType": "WebHook",
        "WebHook": {
          "URI": "{{webhookUrl}}",
          "Headers": {
            "Content-Type": "application/json"
          },
          "Content": {
            "msgtype": "text",
            "text": {
              "content": "Notifikasi: harap setujui restart instance, nama instance untuk disetujui adalah {{getInstance.instanceNames}}, dikirim oleh {{ACS::RegionId}} oos {{ACS::ExecutionId}}."
            },
            "at": {
              "atMobiles": "{{atMobiles}}",
              "isAtAll": "{{atAll}}"
            }
          }
        }
      }
    },
    {
      "Name": "rebootInstance",
      "Action": "ACS::ECS::RebootInstance",
      "Description": {
        "en": "Restarts the ECS instances.",
         
      },
      "Properties": {
        "instanceId": "{{ ACS::TaskLoopItem }}"
      },
      "Loop": {
        "RateControl": "{{ rateControl }}",
        "Items": "{{ getInstance.instanceIds }}"
      }
    }
  ],
  "Outputs": {
    "instanceIds": {
      "Type": "List",
      "Value": "{{ getInstance.instanceIds }}"
    }
  }
}

Sintaks Email

  • Format YAML

Tasks:
  - Action: ACS::Approve
    Name: ApproveByMail
    Properties:
      NotifyType: Mail
      Mail:
      	Host: AlamatServerSMTP # Alamat server Simple Mail Transfer Protocol (SMTP). Contoh: smtp.example1.com.
        Port: NomorPortSMTP # Nomor port server SMTP. Contoh: 465.
        Username: pengirim  # Akun email yang digunakan untuk mengirim notifikasi. Contoh: usr001@example1.com.
        Password: kataSandiPengirim # Kode otorisasi layanan Internet Message Access Protocol (IMAP) atau SMTP, bukan kata sandi akun email.
        Subject: subjekEmail # Subjek notifikasi email. Contoh: halo dunia.
        Body: isiEmail # Isi notifikasi email. Contoh: halo dunia ! ! !. 
        From: alamatPengirim # Alamat email pengirim. Contoh: usr001@example1.com.
        To: # Alamat email penerima. Contoh: usr1234@example2.com,usr123@example2.com.
        	- usr123@example2.com
          - usr1234@example2.com
  • Format JSON (Untuk informasi lebih lanjut, lihat deskripsi atribut untuk format YAML.)

{
  "Tasks": [
    {
      "Action": "ACS::Approve",
      "Name": "ApproveByMail",
      "Properties": {
        "NotifyType": "Mail",
        "Mail": {
          "Host": "AlamatServerSMTP",
          "Port": "NomorPortSMTP",
          "Username": "pengirim",
          "Password": "kataSandiPengirim",
          "Subject": "subjekEmail",
          "Body": "isiEmail",
          "From": "alamatPengirim",
          "To": [
            "usr123@example2.com,usr1234@example2.com"
          ]
        }
      }
    }
  ]
}