Description
L'action ACS::Notify vous avertit de la fin d'une tâche d'exploitation et de maintenance. Par exemple, après l'achat d'une instance Elastic Compute Service (ECS), vous recevez une notification DingTalk et pouvez consulter la facturation en temps réel.
Syntaxe
ACS::Notify prend en charge les notifications par webhook et par e-mail. Utilisez la syntaxe suivante pour configurer ces deux types de notifications.
Webhook
Tasks:
- Name: notifyTask
Action: ACS::Notify
Properties:
NotifyType: WebHook
AppendExecutionLink: 'false' # Specifies whether to append execution links. Valid values: true and false. Default value: false.
WebHook:
URI: url # Required. The webhook URL. Example: https://oapi.dingtalk.com/robot/send?access_token=xxxxxx.
Headers: # Optional. The headers of the HTTP request. Example: Content-Type.
Content-Type: 'application/json; charset=utf-8'
Content: # Required. The content of the webhook notification. Set the value based on the requirements for the webhook. For information about the content of the DingTalk webhook, visit https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1.
msgtype: text
text:
content: 'this is a dingtalk message with a 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": "this is a dingtalk message with a parameter {{ p1 }}"
}
}
}
}
}
]
}Tasks:
- Action: ACS::Notify
Name: NotifyByMail
Properties:
NotifyType: Mail
Mail:
Host: SMTPHostAddress # The Simple Mail Transfer Protocol (SMTP) server address. Example: smtp.example1.com.
Port: SMTPPort # The port number of the SMTP server. Example: 465.
Username: sender # The email account that is used to send the notification. Example: usr001@example1.com.
Password: senderPassword # The password of the email account that is used to send the notification. Example: 123456zxcv.
Subject: mailSubject # The subject of the email notification. Example: hello world.
Body: mailBody # The body of the email notification. Example: hello world!!!
From: senderAddress # The email address of the sender. Example: usr001@example1.com.
To: receiverAddresses # The email addresses of the recipients. Example: [usr1234@example2.com,usr123@example2.com].{
"Tasks": [
{
"Action": "ACS::Notify",
"Name": "NotifyByMail",
"Properties": {
"NotifyType": "Mail",
"Mail": {
"Host": "SMTPHostAddress",
"Port": "SMTPPort",
"Username": "sender",
"Password": "senderPassword",
"Subject": "mailSubject",
"Body": "mailBody",
"From": "senderAddress",
"To": "receiverAddresses"
}
}
}
]
}Exemples
---
FormatVersion: OOS-2019-06-01
Outputs:
InstanceIds:
Type: List
Value: ' {{ runInstances.InstanceIds }} '
Parameters:
ImageId:
Description: the image id for the new instances.
Type: String
InstanceType:
Description: the Instance Type for the new instances.
Type: String
OOSAssumeRole:
Default: OOSServiceRole
Description: oos assume this role to execution task
Type: String
SecurityGroupId:
Description: the security group id for the new instances.
Type: String
VSwitchId:
Description: the virtual switch id for the new instances.
Type: String
RamRole: '{{OOSAssumeRole}}'
Tasks:
- Action: ACS::ExecuteAPI
Description: 'run instances with specified parameters'
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: test
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": "the image id for the new instances.",
"Type": "String"
},
"InstanceType": {
"Description": "the Instance Type for the new instances.",
"Type": "String"
},
"SecurityGroupId": {
"Description": "the security group id for the new instances.",
"Type": "String"
},
"VSwitchId": {
"Description": "the virtual switch id for the new instances.",
"Type": "String"
},
"OOSAssumeRole": {
"Type": "String",
"Description": "oos assume this role to execution task",
"Default": "OOSServiceRole"
}
},
"RamRole": "{{OOSAssumeRole}}",
"Tasks": [
{
"Action": "ACS::ExecuteAPI",
"Description": "run instances with specified parametersl",
"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":"test"
}
}
}
}
}
]
}