テンプレート名
ACS-MNS-PublishMessage
テンプレートの説明
指定された Simple Message Queue (旧称 MNS) Topic にメッセージを公開します。 メッセージが Topic に公開されると、Topic は指定されたエンドポイントにメッセージをプッシュします。
テンプレートタイプ
自動化
所有者
Alibaba Cloud
入力パラメーター
パラメーター | 説明 | データ型 | 必須 | デフォルト値 | 制限 |
topicName | トピック名。 | String | はい | ||
message | Message Service (旧称 MNS) トピックがプッシュするメッセージ。 | String | はい | ||
regionId | リージョン ID。 | String | いいえ | {{ ACS::RegionId }} | |
messageType | Message Service (旧称 MNS) トピックがプッシュするメッセージのタイプ。 | String | いいえ | default | |
messageAttributes | プッシュされたメッセージの属性。 | Json | いいえ | {} | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) によって引き受けられる RAM ロール。 | String | いいえ | "" |
出力パラメーター
パラメーター | 説明 | データ型 |
message | Json |
テンプレートを実行するために必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"mns:PublishMessage"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
参照
テンプレートコンテンツ
FormatVersion: OOS-2019-06-01
Description:
en: Publish a message to the specified MNS topic. After the message is published to the topic, it will be pushed to Endpoint for consumption
name-en: ACS-MNS-PublishMessage
categories:
- security
Parameters:
regionId:
Type: String
Label:
en: RegionId
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
topicName:
Label:
en: TopicName
Type: String
message:
Label:
en: Message
Type: String
messageType:
Label:
en: MessageType
Description:
en: (defalut:to publish a message to the subject of MNS, SMS:to push the message to smsendpoint, mail:to push the message to mailendpoint)
Type: String
Default: default
AllowedValues:
- default
- sms
- mail
messageAttributes:
Label:
en: MessageAttributes
Description:
en: 'Required when message type is SMS and mail (the content of mail and ssm are different, please refer to the document https://help.aliyun.com/document_detail/27497.html).'
Type: Json
Default: {}
OOSAssumeRole:
Label:
en: OOSAssumeRole
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: publishMessage
When:
'Fn::Equals':
- '{{ messageType }}'
- default
Action: 'ACS::ExecuteAPI'
Description:
en: Publish a message to the specified topic
Properties:
Service: MNS
API: PublishMessage
Method: POST
URI: '/topics/{{ topicName }}/messages'
Headers: {}
Parameters:
RegionId: '{{ regionId }}'
AccountId: '{{ ACS::AccountId }}'
Body: '<?xml version="1.0" encoding="utf-8"?><Message xmlns="http://mns.aliyuncs.com/doc/v1/"><MessageBody>{{ message }}</MessageBody></Message>'
Outputs:
message:
Type: Json
ValueSelector: .
- Name: publishSmsMessage
When:
'Fn::Equals':
- '{{ messageType }}'
- sms
Action: 'ACS::ExecuteAPI'
Description:
en: Publish a message to the specified topic abourt sms, and push it to sms endpoint
Properties:
Service: MNS
API: PublishMessage
Method: POST
URI: '/topics/{{ topicName }}/messages'
Headers: {}
Parameters:
RegionId: '{{ regionId }}'
AccountId: '{{ ACS::AccountId }}'
Body: '<?xml version="1.0" encoding="utf-8"?><Message xmlns="http://mns.aliyuncs.com/doc/v1/"><MessageBody>{{ message }}</MessageBody><MessageAttributes><DirectSMS>{{ messageAttributes }}</DirectSMS></MessageAttributes></Message>'
Outputs:
message:
Type: Json
ValueSelector: .
- Name: publishMailMessage
When:
'Fn::Equals':
- '{{ messageType }}'
- mail
Action: 'ACS::ExecuteAPI'
Description:
en: Publish a message to the specified topic abourt mail, and push it to mail endpoint
Properties:
Service: MNS
API: PublishMessage
Method: POST
URI: '/topics/{{ topicName }}/messages'
Headers: {}
Parameters:
RegionId: '{{ regionId }}'
AccountId: '{{ ACS::AccountId }}'
Body: '<?xml version="1.0" encoding="utf-8"?><Message xmlns="http://mns.aliyuncs.com/doc/v1/"><MessageBody>{{ message }}</MessageBody><MessageAttributes><DirectMail>{{ messageAttributes }}</DirectMail></MessageAttributes></Message>'
Outputs:
message:
Type: Json
ValueSelector: .
Outputs:
message:
Type: Json
Value:
'Fn::If':
- 'Fn::Equals':
- default
- '{{ messageType }}'
- '{{ publishMessage.message }}'
- 'Fn::If':
- 'Fn::Equals':
- ssm
- '{{ messageType }}'
- '{{ publishSmsMessage.message }}'
- '{{ publishMailMessage.message }}'