The SNS (sns
) action sends the data from an MQTT message as an Amazon Simple Notification Service (Amazon SNS) push notification.
You can follow a tutorial that shows you how to create and test a rule with an SNS action. For more information, see Tutorial: Sending an Amazon SNS notification.
RequirementsThis rule action has the following requirements:
An IAM role that AWS IoT can assume to perform the sns:Publish
operation. For more information, see Granting an AWS IoT rule the access it requires.
In the AWS IoT console, you can choose or create a role to allow AWS IoT to perform this rule action.
If you use an AWS KMS customer managed-managed AWS KMS key to encrypt data at rest in Amazon SNS, the service must have permission to use the AWS KMS key on the caller's behalf. For more information, see Key management in the Amazon Simple Notification Service Developer Guide.
When you create an AWS IoT rule with this action, you must specify the following information:
targetArn
The SNS topic or individual device to which the push notification is sent.
Supports substitution templates: API and AWS CLI only
messageFormat
(Optional) The message format. Amazon SNS uses this setting to determine if the payload should be parsed and if relevant platform-specific parts of the payload should be extracted. Valid values: JSON
, RAW
. Defaults to RAW
.
Supports substitution templates: No
roleArn
The IAM role that allows access to SNS. For more information, see Requirements.
Supports substitution templates: No
The following JSON example defines an SNS action in an AWS IoT rule.
{
"topicRulePayload": {
"sql": "SELECT * FROM 'some/topic'",
"ruleDisabled": false,
"awsIotSqlVersion": "2016-03-23",
"actions": [
{
"sns": {
"targetArn": "arn:aws:sns:us-east-2:123456789012:my_sns_topic",
"roleArn": "arn:aws:iam::123456789012:role/aws_iot_sns"
}
}
]
}
}
The following JSON example defines an SNS action with substitution templates in an AWS IoT rule.
{
"topicRulePayload": {
"sql": "SELECT * FROM 'some/topic'",
"ruleDisabled": false,
"awsIotSqlVersion": "2016-03-23",
"actions": [
{
"sns": {
"targetArn": "arn:aws:sns:us-east-1:123456789012:${topic()}",
"messageFormat": "JSON",
"roleArn": "arn:aws:iam::123456789012:role/aws_iot_sns"
}
}
]
}
}
See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4