Skip to content
v2.277.0

Experimental

@aws-cdk/aws-iot-actions-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

KinesisPutRecordAction Class ​

The action to put the record from an MQTT message to the Kinesis Data stream.

Example ​

ts
import * as kinesis from 'aws-cdk-lib/aws-kinesis';

const stream = new kinesis.Stream(this, 'MyStream');

const topicRule = new iot.TopicRule(this, 'TopicRule', {
  sql: iot.IotSql.fromStringAsVer20160323("SELECT * FROM 'device/+/data'"),
  actions: [
    new actions.KinesisPutRecordAction(stream, {
      partitionKey: '${newuuid()}',
    }),
  ],
});
python
import aws_cdk.aws_kinesis as kinesis


stream = kinesis.Stream(self, "MyStream")

topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT * FROM 'device/+/data'"),
    actions=[
        actions.KinesisPutRecordAction(stream,
            partition_key="${newuuid()}"
        )
    ]
)
java
import software.amazon.awscdk.services.kinesis.*;


Stream stream = new Stream(this, "MyStream");

TopicRule topicRule = TopicRule.Builder.create(this, "TopicRule")
        .sql(IotSql.fromStringAsVer20160323("SELECT * FROM 'device/+/data'"))
        .actions(List.of(
            KinesisPutRecordAction.Builder.create(stream)
                    .partitionKey("${newuuid()}")
                    .build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.IoT.Actions.Alpha
using Amazon.CDK.AWS.Kinesis;


var stream = new Stream(this, "MyStream");

var topicRule = new TopicRule(this, "TopicRule", new TopicRuleProps {
    Sql = IotSql.FromStringAsVer20160323("SELECT * FROM 'device/+/data'"),
    Actions = new [] {
        new KinesisPutRecordAction(stream, new KinesisPutRecordActionProps {
            PartitionKey = "${newuuid()}"
        }) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkiotactionsalpha/v2
import kinesis "github.com/aws/aws-cdk-go/awscdk"


stream := kinesis.NewStream(this, jsii.String("MyStream"))

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []IAction{
		actions.NewKinesisPutRecordAction(stream, &KinesisPutRecordActionProps{
			PartitionKey: jsii.String("${newuuid()}"),
		}),
	},
})

Initializer ​

ts
new KinesisPutRecordAction(stream: IStream, props: KinesisPutRecordActionProps)
python
KinesisPutRecordAction(stream: IStream, props: KinesisPutRecordActionProps)
java
new KinesisPutRecordAction(IStream stream, KinesisPutRecordActionProps props)
csharp
new KinesisPutRecordAction(IStream stream, KinesisPutRecordActionProps props)
go
NewKinesisPutRecordAction(Stream IStream, Props KinesisPutRecordActionProps)