全部产品
Search
文档中心

CloudOps Orchestration Service:ACS::Notify

更新时间:Jun 28, 2025

Deskripsi

Aksi ACS::Notify memberi tahu Anda saat tugas O&M selesai. Sebagai contoh, setelah membeli instance Elastic Compute Service (ECS), notifikasi DingTalk akan dikirim kepada Anda sehingga Anda dapat melihat tagihan secara real-time.

Sintaksis

ACS::Notify mendukung notifikasi webhook dan email. Gunakan sintaksis berikut untuk mengonfigurasi notifikasi webhook dan email.

Webhook

Tasks:
  - Name: notifyTask
    Action: ACS::Notify
    Properties:
      NotifyType: WebHook
	  AppendExecutionLink: 'false' # Menentukan apakah akan menambahkan tautan eksekusi. Nilai yang valid: true dan false. Nilai default: false.
      WebHook:
        URI: url # Diperlukan. 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: # Diperlukan. 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: 'ini adalah pesan dingtalk dengan parameter {{ p1 }}'
{
  "Tasks": [
    {
      "Name": "notifyTask",
      "Action": "ACS::Notify",
      "Properties": {
        "NotifyType": "WebHook",
        "AppendExecutionLink": "false",
        "WebHook": {
          "URI": "url",
          "Headers": {
            "Content-Type": "application/json; charset=utf-8"
          },
          "Content": {
            "msgtype": "text",
            "text": {
              "content": "ini adalah pesan dingtalk dengan parameter {{ p1 }}"
            }
          }
        }
      }
    }
  ]
}

Surat

Tasks:
  - Action: ACS::Notify
    Name: NotifyByMail
    Properties:
      NotifyType: Mail
      Mail:
        Host: SMTPHostAddress # Alamat server Simple Mail Transfer Protocol (SMTP). Contoh: smtp.example1.com.
        Port: SMTPPort # Nomor port server SMTP. Contoh: 465.
        Username: pengirim # Akun email yang digunakan untuk mengirim notifikasi. Contoh: usr001@example1.com.
        Password: senderPassword # Kata sandi akun email yang digunakan untuk mengirim notifikasi. Contoh: 123456zxcv.
        Subject: mailSubject # Subjek notifikasi email. Contoh: halo dunia.
        Body: mailBody # Isi notifikasi email. Contoh: halo dunia!!!   
        From: senderAddress # Alamat email pengirim. Contoh: usr001@example1.com.
        To: receiverAddresses # Alamat email penerima. Contoh: [usr1234@example2.com,usr123@example2.com].
{
  "Tasks": [
    {
      "Action": "ACS::Notify",
      "Name": "NotifyByMail",
      "Properties": {
        "NotifyType": "Mail",
        "Mail": {
          "Host": "SMTPHostAddress",
          "Port": "SMTPPort",
          "Username": "pengirim",
          "Password": "senderPassword",
          "Subject": "mailSubject",
          "Body": "mailBody",
          "From": "senderAddress",
          "To": "receiverAddresses"
        }
      }
    }
  ]
}

Contoh

---
FormatVersion: OOS-2019-06-01
Outputs:
    InstanceIds:
        Type: List
        Value: ' {{ runInstances.InstanceIds }} '
Parameters:
    ImageId:
        Description: id gambar untuk instance baru.
        Type: String
    InstanceType:
        Description: Tipe Instance untuk instance baru.
        Type: String
    OOSAssumeRole:
        Default: OOSServiceRole
        Description: oos mengasumsikan peran ini untuk menjalankan tugas
        Type: String
    SecurityGroupId:
        Description: id grup keamanan untuk instance baru.
        Type: String
    VSwitchId:
        Description: id switch virtual untuk instance baru.
        Type: String
RamRole: '{{OOSAssumeRole}}'
Tasks:
-   Action: ACS::ExecuteAPI
    Description: 'menjalankan instance dengan parameter tertentu'
    Name: runInstances
    Outputs:
        InstanceIds:
            Type: List
            ValueSelector: .InstanceIdSets.InstanceIdSet[]
    Properties:
        API: RunInstances
        Parameters:
            ImageId: '{{ ImageId }}'
            InstanceType: '{{ InstanceType }}'
            SecurityGroupId: '{{ SecurityGroupId }}'
            VSwitchId: '{{ VSwitchId }}'
        Service: ECS
-   Action: ACS::Notify
    Name: test_notify
    Properties:
        NotifyType: WebHook
        WebHook:
            Content:
                msgtype: text
                text: 
                  content: tes
            Headers:
                Content-Type: application/json
            URI: https://oapi.dingtalk.com/robot/send?access_token=your_access_token
{
    "FormatVersion": "OOS-2019-06-01",
    "Outputs": {
        "InstanceIds": {
            "Type": "List"
            "Value": " {{ runInstances.InstanceIds }} "
        }
    },
    "Parameters": {
        "ImageId": {
            "Description": "id gambar untuk instance baru.",
            "Type": "String"
        },
        "InstanceType": {
            "Description": "Tipe Instance untuk instance baru.",
            "Type": "String"
        },
        "SecurityGroupId": {
            "Description": "id grup keamanan untuk instance baru.",
            "Type": "String"
        },
        "VSwitchId": {
            "Description": "id switch virtual untuk instance baru.",
            "Type": "String"
        },
          "OOSAssumeRole": {
      		"Type": "String",
      		"Description":  "oos mengasumsikan peran ini untuk menjalankan tugas",
      		"Default": "OOSServiceRole"
    }
    },
    "RamRole": "{{OOSAssumeRole}}",
    "Tasks": [
        {
            "Action": "ACS::ExecuteAPI",
            "Description": "menjalankan instance dengan parameter tertentu",
            "Name": "runInstances",
            "Outputs": {
                "InstanceIds": {
                    "Type": "List",
                    "ValueSelector": ".InstanceIdSets.InstanceIdSet[]"
                }
            },
            "Properties": {
                "API": "RunInstances",
                "Parameters": {
                    "ImageId": "{{ ImageId }}",
                    "InstanceType": "{{ InstanceType }}",
                    "SecurityGroupId": "{{ SecurityGroupId }}",
                    "VSwitchId": "{{ VSwitchId }}"
                },
                "Service": "ECS"
            }
        },
       {
      "Name": "test_notify",
      "Action": "ACS::Notify",
      "Properties": {
        "NotifyType": "WebHook",
        "WebHook": {
          "URI": "https://oapi.dingtalk.com/robot/send?access_token=your_access_token",
          "Headers": {
            "Content-Type": "application/json"
          },
          "Content": {
            "msgtype": "text",
            "text": {
              "content":"tes"
            }
          }
        }
      }
    } 
    ]
}