@aws-cdk_aws-iot-actions-alpha.SnsTopicAction

class SnsTopicAction 🔹

LanguageType name
.NETAmazon.CDK.AWS.IoT.Actions.Alpha.SnsTopicAction
Gogithub.com/aws/aws-cdk-go/awscdkiotactionsalpha/v2#SnsTopicAction
Javasoftware.amazon.awscdk.services.iot.actions.alpha.SnsTopicAction
Pythonaws_cdk.aws_iot_actions_alpha.SnsTopicAction
TypeScript (source)@aws-cdk/aws-iot-actions-alpha » SnsTopicAction

Implements IAction

The action to write the data from an MQTT message to an Amazon SNS topic.

See also: https://docs.aws.amazon.com/iot/latest/developerguide/sns-rule-action.html

Example

import * as sns from 'aws-cdk-lib/aws-sns';

const topic = new sns.Topic(this, 'MyTopic');

const topicRule = new iot.TopicRule(this, 'TopicRule', {
  sql: iot.IotSql.fromStringAsVer20160323(
    "SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'",
  ),
  actions: [
    new actions.SnsTopicAction(topic, {
      messageFormat: actions.SnsActionMessageFormat.JSON, // optional property, default is SnsActionMessageFormat.RAW
    }),
  ],
});

Initializer

new SnsTopicAction(topic: ITopic, props?: SnsTopicActionProps)

Parameters

  • topic ITopic — The Amazon SNS topic to publish data on.
  • props SnsTopicActionProps — Properties to configure the action.