Experimental
@aws-cdk/aws-iot-actions-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
IotEventsPutMessageAction Class
The action to put the message from an MQTT message to the IoT Events input.
Example
ts
import * as iotevents from '@aws-cdk/aws-iotevents-alpha';
import * as iam from 'aws-cdk-lib/aws-iam';
declare const role: iam.IRole;
const input = new iotevents.Input(this, 'MyInput', {
attributeJsonPaths: ['payload.temperature', 'payload.transactionId'],
});
const topicRule = new iot.TopicRule(this, 'TopicRule', {
sql: iot.IotSql.fromStringAsVer20160323(
"SELECT * FROM 'device/+/data'",
),
actions: [
new actions.IotEventsPutMessageAction(input, {
batchMode: true, // optional property, default is 'false'
messageId: '${payload.transactionId}', // optional property, default is a new UUID
role: role, // optional property, default is a new UUID
}),
],
});
python
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iam as iam
# role: iam.IRole
input = iotevents.Input(self, "MyInput",
attribute_json_paths=["payload.temperature", "payload.transactionId"]
)
topic_rule = iot.TopicRule(self, "TopicRule",
sql=iot.IotSql.from_string_as_ver20160323("SELECT * FROM 'device/+/data'"),
actions=[
actions.IotEventsPutMessageAction(input,
batch_mode=True, # optional property, default is 'false'
message_id="${payload.transactionId}", # optional property, default is a new UUID
role=role
)
]
)
java
import software.amazon.awscdk.services.iotevents.alpha.*;
import software.amazon.awscdk.services.iam.*;
IRole role;
Input input = Input.Builder.create(this, "MyInput")
.attributeJsonPaths(List.of("payload.temperature", "payload.transactionId"))
.build();
TopicRule topicRule = TopicRule.Builder.create(this, "TopicRule")
.sql(IotSql.fromStringAsVer20160323("SELECT * FROM 'device/+/data'"))
.actions(List.of(
IotEventsPutMessageAction.Builder.create(input)
.batchMode(true) // optional property, default is 'false'
.messageId("${payload.transactionId}") // optional property, default is a new UUID
.role(role)
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.IoT.Actions.Alpha
using Amazon.CDK.AWS.IoTEvents.Alpha;
using Amazon.CDK.AWS.IAM;
IRole role;
var input = new Input(this, "MyInput", new InputProps {
AttributeJsonPaths = new [] { "payload.temperature", "payload.transactionId" }
});
var topicRule = new TopicRule(this, "TopicRule", new TopicRuleProps {
Sql = IotSql.FromStringAsVer20160323("SELECT * FROM 'device/+/data'"),
Actions = new [] {
new IotEventsPutMessageAction(input, new IotEventsPutMessageActionProps {
BatchMode = true, // optional property, default is 'false'
MessageId = "${payload.transactionId}", // optional property, default is a new UUID
Role = role
}) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkiotactionsalpha/v2
import iotevents "github.com/aws/aws-cdk-go/awscdkioteventsalpha"
import iam "github.com/aws/aws-cdk-go/awscdk"
var role IRole
input := iotevents.NewInput(this, jsii.String("MyInput"), &InputProps{
AttributeJsonPaths: []*string{
jsii.String("payload.temperature"),
jsii.String("payload.transactionId"),
},
})
topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
Actions: []IAction{
actions.NewIotEventsPutMessageAction(input, &IotEventsPutMessageActionProps{
BatchMode: jsii.Boolean(true),
// optional property, default is 'false'
MessageId: jsii.String("${payload.transactionId}"),
// optional property, default is a new UUID
Role: role,
}),
},
})
Initializer
ts
new IotEventsPutMessageAction(input: IInput, props?: IotEventsPutMessageActionProps)
python
IotEventsPutMessageAction(input: IInput, props: typing.Optional[IotEventsPutMessageActionProps] = None)
java
new IotEventsPutMessageAction(IInput input, IotEventsPutMessageActionProps props)
csharp
new IotEventsPutMessageAction(IInput input, IotEventsPutMessageActionProps? props = null)
go
NewIotEventsPutMessageAction(Input IInput, Props IotEventsPutMessageActionProps)