All Products
Search
Document Center

ACS__Notify

Last Updated: Jun 11, 2020

Features

The ACS::Notify action allows you to be notified after an O&M operation is completed. For example, after an ECS instance is purchased, you can receive a DingTalk notification to learn about the bill in real time.

Syntax

Currently, webhook and email notifications are supported. Use the following syntaxes to define webhook and email notifications:

Webhook

  • YAML format
  1. Tasks:
  2. - Name: notifyTask
  3. Action: ACS::Notify
  4. Properties:
  5. NotifyType: WebHook
  6. AppendExecutionLink: 'false' # Append execution link or not . ACS::Notify default option is false.
  7. WebHook:
  8. URI: url # Required. The webhook URL, such as https://oapi.dingtalk.com/robot/send?access_token=xxxxxx.
  9. Headers: # Optional. The headers of the Hypertext Transfer Protocol (HTTP) request, such as Content-Type.
  10. Content-Type: 'application/json; charset=utf-8'
  11. Content: # Required. This attribute is set based on the specific requirements of webhooks. For more information about the content of the DingTalk webhook, see https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1.
  12. msgtype: text
  13. text:
  14. content: 'this is a dingtalk message with a parameter {{ p1 }}'
  • JSON format (For more information, see the parameter description for the YAML format.)
  1. {
  2. "Tasks": [
  3. {
  4. "Name": "notifyTask",
  5. "Action": "ACS::Notify",
  6. "Properties": {
  7. "NotifyType": "WebHook",
  8. "AppendExecutionLink": "false",
  9. "WebHook": {
  10. "URI": "url",
  11. "Headers": {
  12. "Content-Type": "application/json; charset=utf-8"
  13. },
  14. "Content": {
  15. "msgtype": "text",
  16. "text": {
  17. "content": "this is a dingtalk message with a parameter {{ p1 }}"
  18. }
  19. }
  20. }
  21. }
  22. }
  23. ]
  24. }

Email

  • YAML format
  1. Tasks:
  2. - Action: ACS::Notify
  3. Name: testNotifyByMail
  4. Properties:
  5. NotifyType: Mail
  6. Mail:
  7. Host: SMTPHostAddress # The Simple Mail Transfer Protocol (SMTP) server address, for example, smtp.example1.com.
  8. Port: SMTPPort # The SMTP server port, such as port 465.
  9. Username: sender # The email account for sending the notification, such as usr001@example1.com.
  10. Password: senderPassword # The password of the email account for sending the notification, such as 123456zxcv.
  11. Subject: mailSubject # The subject of the email, such as hello world.
  12. Body: mailBody # The body of the email, such as hello world!!!.
  13. From: senderAddress # The email address of the sender, such as usr001@example1.com.
  14. To: receiverAddresses # The email addresses of the recipients, such as [usr1234@example2.com,usr123@example2.com].
  • JSON format (For more information, see the parameter description for the YAML format.)
  1. {
  2. "Tasks": [
  3. {
  4. "Action": "ACS::Notify",
  5. "Name": "testNotifyByMail",
  6. "Properties": {
  7. "NotifyType": "Mail",
  8. "Mail": {
  9. "Host": "SMTPHostAddress",
  10. "Port": "SMTPPort",
  11. "Username": "sender",
  12. "Password": "senderPassword",
  13. "Subject": "mailSubject",
  14. "Body": "mailBody",
  15. "From": "senderAddress",
  16. "To": "receiverAddresses"
  17. }
  18. }
  19. }
  20. ]
  21. }

Example

  • YAML format
  1. ---
  2. FormatVersion: OOS-2019-06-01
  3. Outputs:
  4. InstanceIds:
  5. Type: List
  6. Value: ' {{ runInstances.InstanceIds }} '
  7. Parameters:
  8. ImageId:
  9. Description: the image id for the new instances.
  10. Type: String
  11. InstanceType:
  12. Description: the Instance Type for the new instances.
  13. Type: String
  14. OOSAssumeRole:
  15. Default: OOSServiceRole
  16. Description: oos assume this role to execution task
  17. Type: String
  18. SecurityGroupId:
  19. Description: the security group id for the new instances.
  20. Type: String
  21. VSwitchId:
  22. Description: the virtual switch id for the new instances.
  23. Type: String
  24. RamRole: '{{OOSAssumeRole}}'
  25. Tasks:
  26. - Action: ACS::ExecuteAPI
  27. Description: 'run instances with specified parameters, refer them here: https://www.alibabacloud.com/help/doc-detail/63440.html'
  28. Name: runInstances
  29. Outputs:
  30. InstanceIds:
  31. Type: List
  32. ValueSelector: .InstanceIdSets.InstanceIdSet[]
  33. Properties:
  34. API: RunInstances
  35. Parameters:
  36. ImageId: '{{ ImageId }}'
  37. InstanceType: '{{ InstanceType }}'
  38. SecurityGroupId: '{{ SecurityGroupId }}'
  39. VSwitchId: '{{ VSwitchId }}'
  40. Service: ECS
  41. - Action: ACS::Notify
  42. Name: test_notify
  43. Properties:
  44. NotifyType: WebHook
  45. WebHook:
  46. Content:
  47. msgtype: text
  48. text:
  49. content:
  50. Headers:
  51. Content-Type: application/json
  52. URI: https://oapi.dingtalk.com/robot/send?access_token=your_access_token
  • JSON format
  1. {
  2. "FormatVersion": "OOS-2019-06-01",
  3. "Outputs": {
  4. "InstanceIds": {
  5. "Type": "List"
  6. "Value": " {{ runInstances.InstanceIds }} "
  7. }
  8. },
  9. "Parameters": {
  10. "ImageId": {
  11. "Description": "the image id for the new instances.",
  12. "Type": "String"
  13. },
  14. "InstanceType": {
  15. "Description": "the Instance Type for the new instances.",
  16. "Type": "String"
  17. },
  18. "SecurityGroupId": {
  19. "Description": "the security group id for the new instances.",
  20. "Type": "String"
  21. },
  22. "VSwitchId": {
  23. "Description": "the virtual switch id for the new instances.",
  24. "Type": "String"
  25. },
  26. "OOSAssumeRole": {
  27. "Type": "String",
  28. "Description": "oos assume this role to execution task",
  29. "Default": "OOSServiceRole"
  30. }
  31. },
  32. "RamRole": "{{OOSAssumeRole}}",
  33. "Tasks": [
  34. {
  35. "Action": "ACS::ExecuteAPI",
  36. "Description": "run instances with specified parameters, refer them here: https://www.alibabacloud.com/help/doc-detail/63440.html",
  37. "Name": "runInstances",
  38. "Outputs": {
  39. "InstanceIds": {
  40. "Type": "List",
  41. "ValueSelector": ".InstanceIdSets.InstanceIdSet[]"
  42. }
  43. },
  44. "Properties": {
  45. "API": "RunInstances",
  46. "Parameters": {
  47. "ImageId": "{{ ImageId }}",
  48. "InstanceType": "{{ InstanceType }}",
  49. "SecurityGroupId": "{{ SecurityGroupId }}",
  50. "VSwitchId": "{{ VSwitchId }}"
  51. },
  52. "Service": "ECS"
  53. }
  54. },
  55. {
  56. "Name": "test_notify",
  57. "Action": "ACS::Notify",
  58. "Properties": {
  59. "NotifyType": "WebHook",
  60. "WebHook": {
  61. "URI": "https://oapi.dingtalk.com/robot/send?access_token=your_access_token",
  62. "Headers": {
  63. "Content-Type": "application/json"
  64. },
  65. "Content": {
  66. "msgtype": "text",
  67. "text": {
  68. "content":"test"
  69. }
  70. }
  71. }
  72. }
  73. }
  74. ]
  75. }