awscdkiotactionsalpha

package module
v2.145.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

Actions for AWS IoT Rule

---

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


This library contains integration classes to send data to any number of supported AWS Services. Instances of these classes should be passed to TopicRule defined in aws-cdk-lib/aws-iot.

Currently supported are:

  • Republish a message to another MQTT topic
  • Invoke a Lambda function
  • Put objects to a S3 bucket
  • Put logs to CloudWatch Logs
  • Capture CloudWatch metrics
  • Change state for a CloudWatch alarm
  • Put records to Kinesis Data stream
  • Put records to Kinesis Data Firehose stream
  • Send messages to SQS queues
  • Publish messages on SNS topics
  • Write messages into columns of DynamoDB
  • Put messages IoT Events input
  • Send messages to HTTPS endpoints

Republish a message to another MQTT topic

The code snippet below creates an AWS IoT Rule that republish a message to another MQTT topic when it is triggered.

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewIotRepublishMqttAction(jsii.String("${topic()}/republish"), &IotRepublishMqttActionProps{
			QualityOfService: actions.MqttQualityOfService_AT_LEAST_ONCE,
		}),
	},
})

Invoke a Lambda function

The code snippet below creates an AWS IoT Rule that invoke a Lambda function when it is triggered.

func := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromInline(jsii.String(`
	    exports.handler = (event) => {
	      console.log("It is test for lambda action of AWS IoT Rule.", event);
	    };`)),
})

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewLambdaFunctionAction(func),
	},
})

Put objects to a S3 bucket

The code snippet below creates an AWS IoT Rule that puts objects to a S3 bucket when it is triggered.

bucket := s3.NewBucket(this, jsii.String("MyBucket"))

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewS3PutObjectAction(bucket),
	},
})

The property key of S3PutObjectAction is given the value ${topic()}/${timestamp()} by default. This ${topic()} and ${timestamp()} is called Substitution templates. For more information see this documentation. In above sample, ${topic()} is replaced by a given MQTT topic as device/001/data. And ${timestamp()} is replaced by the number of the current timestamp in milliseconds as 1636289461203. So if the MQTT broker receives an MQTT topic device/001/data on 2021-11-07T00:00:00.000Z, the S3 bucket object will be put to device/001/data/1636243200000.

You can also set specific key as following:

bucket := s3.NewBucket(this, jsii.String("MyBucket"))

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewS3PutObjectAction(bucket, &S3PutObjectActionProps{
			Key: jsii.String("${year}/${month}/${day}/${topic(2)}"),
		}),
	},
})

If you wanna set access control to the S3 bucket object, you can specify accessControl as following:

bucket := s3.NewBucket(this, jsii.String("MyBucket"))

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewS3PutObjectAction(bucket, &S3PutObjectActionProps{
			AccessControl: s3.BucketAccessControl_PUBLIC_READ,
		}),
	},
})

Put logs to CloudWatch Logs

The code snippet below creates an AWS IoT Rule that puts logs to CloudWatch Logs when it is triggered.

import logs "github.com/aws/aws-cdk-go/awscdk"


logGroup := logs.NewLogGroup(this, jsii.String("MyLogGroup"))

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewCloudWatchLogsAction(logGroup),
	},
})

Capture CloudWatch metrics

The code snippet below creates an AWS IoT Rule that capture CloudWatch metrics when it is triggered.

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, namespace, unit, value, timestamp FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewCloudWatchPutMetricAction(&CloudWatchPutMetricActionProps{
			MetricName: jsii.String("${topic(2)}"),
			MetricNamespace: jsii.String("${namespace}"),
			MetricUnit: jsii.String("${unit}"),
			MetricValue: jsii.String("${value}"),
			MetricTimestamp: jsii.String("${timestamp}"),
		}),
	},
})

Start Step Functions State Machine

The code snippet below creates an AWS IoT Rule that starts a Step Functions State Machine when it is triggered.

stateMachine := stepfunctions.NewStateMachine(this, jsii.String("SM"), &StateMachineProps{
	DefinitionBody: stepfunctions.DefinitionBody_FromChainable(stepfunctions.NewWait(this, jsii.String("Hello"), &WaitProps{
		Time: stepfunctions.WaitTime_Duration(awscdk.Duration_Seconds(jsii.Number(10))),
	})),
})

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewStepFunctionsStateMachineAction(stateMachine),
	},
})

Change the state of an Amazon CloudWatch alarm

The code snippet below creates an AWS IoT Rule that changes the state of an Amazon CloudWatch alarm when it is triggered:

import "github.com/aws/aws-cdk-go/awscdk"


metric := cloudwatch.NewMetric(&MetricProps{
	Namespace: jsii.String("MyNamespace"),
	MetricName: jsii.String("MyMetric"),
	DimensionsMap: map[string]*string{
		"MyDimension": jsii.String("MyDimensionValue"),
	},
})
alarm := cloudwatch.NewAlarm(this, jsii.String("MyAlarm"), &AlarmProps{
	Metric: metric,
	Threshold: jsii.Number(100),
	EvaluationPeriods: jsii.Number(3),
	DatapointsToAlarm: jsii.Number(2),
})

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewCloudWatchSetAlarmStateAction(alarm, &CloudWatchSetAlarmStateActionProps{
			Reason: jsii.String("AWS Iot Rule action is triggered"),
			AlarmStateToSet: cloudwatch.AlarmState_ALARM,
		}),
	},
})

Put records to Kinesis Data stream

The code snippet below creates an AWS IoT Rule that puts records to Kinesis Data stream when it is triggered.

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()}"),
		}),
	},
})

Put records to Kinesis Data Firehose stream

The code snippet below creates an AWS IoT Rule that puts records to Put records to Kinesis Data Firehose stream when it is triggered.

import firehose "github.com/aws/aws-cdk-go/awscdkkinesisfirehosealpha"
import destinations "github.com/aws/aws-cdk-go/awscdkkinesisfirehosedestinationsalpha"


bucket := s3.NewBucket(this, jsii.String("MyBucket"))
stream := firehose.NewDeliveryStream(this, jsii.String("MyStream"), &DeliveryStreamProps{
	Destinations: []iDestination{
		destinations.NewS3Bucket(bucket),
	},
})

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewFirehosePutRecordAction(stream, &FirehosePutRecordActionProps{
			BatchMode: jsii.Boolean(true),
			RecordSeparator: actions.FirehoseRecordSeparator_NEWLINE,
		}),
	},
})

Send messages to an SQS queue

The code snippet below creates an AWS IoT Rule that send messages to an SQS queue when it is triggered:

import sqs "github.com/aws/aws-cdk-go/awscdk"


queue := sqs.NewQueue(this, jsii.String("MyQueue"))

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewSqsQueueAction(queue, &SqsQueueActionProps{
			UseBase64: jsii.Boolean(true),
		}),
	},
})

Publish messages on an SNS topic

The code snippet below creates and AWS IoT Rule that publishes messages to an SNS topic when it is triggered:

import sns "github.com/aws/aws-cdk-go/awscdk"


topic := sns.NewTopic(this, jsii.String("MyTopic"))

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewSnsTopicAction(topic, &SnsTopicActionProps{
			MessageFormat: actions.SnsActionMessageFormat_JSON,
		}),
	},
})

Write attributes of a message to DynamoDB

The code snippet below creates an AWS IoT rule that writes all or part of an MQTT message to DynamoDB using the DynamoDBv2 action.

import dynamodb "github.com/aws/aws-cdk-go/awscdk"

var table table


topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewDynamoDBv2PutItemAction(table),
	},
})

Put messages IoT Events input

The code snippet below creates an AWS IoT Rule that puts messages to an IoT Events input when it is triggered:

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,
		}),
	},
})

Send Messages to HTTPS Endpoints

The code snippet below creates an AWS IoT Rule that sends messages to an HTTPS endpoint when it is triggered:

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
})

topicRule.AddAction(
actions.NewHttpsAction(jsii.String("https://example.com/endpoint"), &HttpsActionProps{
	ConfirmationUrl: jsii.String("https://example.com"),
	Headers: []httpActionHeader{
		&httpActionHeader{
			Key: jsii.String("key0"),
			Value: jsii.String("value0"),
		},
		&httpActionHeader{
			Key: jsii.String("key1"),
			Value: jsii.String("value1"),
		},
	},
	Auth: &HttpActionSigV4Auth{
		ServiceName: jsii.String("serviceName"),
		SigningRegion: jsii.String("us-east-1"),
	},
}))

Write Data to Open Search Service

The code snippet below creates an AWS IoT Rule that writes data to an Open Search Service when it is triggered:

import opensearch "github.com/aws/aws-cdk-go/awscdk"
var domain domain


topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
})

topicRule.AddAction(actions.NewOpenSearchAction(domain, &OpenSearchActionProps{
	Id: jsii.String("my-id"),
	Index: jsii.String("my-index"),
	Type: jsii.String("my-type"),
}))

Documentation

Overview

Receipt rule actions for AWS IoT

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCloudWatchLogsAction_Override

func NewCloudWatchLogsAction_Override(c CloudWatchLogsAction, logGroup awslogs.ILogGroup, props *CloudWatchLogsActionProps)

Experimental.

func NewCloudWatchPutMetricAction_Override

func NewCloudWatchPutMetricAction_Override(c CloudWatchPutMetricAction, props *CloudWatchPutMetricActionProps)

Experimental.

func NewCloudWatchSetAlarmStateAction_Override

func NewCloudWatchSetAlarmStateAction_Override(c CloudWatchSetAlarmStateAction, alarm awscloudwatch.IAlarm, props *CloudWatchSetAlarmStateActionProps)

Experimental.

func NewDynamoDBv2PutItemAction_Override

func NewDynamoDBv2PutItemAction_Override(d DynamoDBv2PutItemAction, table awsdynamodb.ITable, props *DynamoDBv2PutItemActionProps)

Experimental.

func NewFirehosePutRecordAction_Override

func NewFirehosePutRecordAction_Override(f FirehosePutRecordAction, stream awscdkkinesisfirehosealpha.IDeliveryStream, props *FirehosePutRecordActionProps)

Experimental.

func NewHttpsAction_Override

func NewHttpsAction_Override(h HttpsAction, url *string, props *HttpsActionProps)

Experimental.

func NewIotEventsPutMessageAction_Override

func NewIotEventsPutMessageAction_Override(i IotEventsPutMessageAction, input awscdkioteventsalpha.IInput, props *IotEventsPutMessageActionProps)

Experimental.

func NewIotRepublishMqttAction_Override

func NewIotRepublishMqttAction_Override(i IotRepublishMqttAction, topic *string, props *IotRepublishMqttActionProps)

Experimental.

func NewKinesisPutRecordAction_Override

func NewKinesisPutRecordAction_Override(k KinesisPutRecordAction, stream awskinesis.IStream, props *KinesisPutRecordActionProps)

Experimental.

func NewLambdaFunctionAction_Override

func NewLambdaFunctionAction_Override(l LambdaFunctionAction, func_ awslambda.IFunction)

Experimental.

func NewOpenSearchAction_Override

func NewOpenSearchAction_Override(o OpenSearchAction, domain awsopensearchservice.Domain, props *OpenSearchActionProps)

Experimental.

func NewS3PutObjectAction_Override

func NewS3PutObjectAction_Override(s S3PutObjectAction, bucket awss3.IBucket, props *S3PutObjectActionProps)

Experimental.

func NewSnsTopicAction_Override

func NewSnsTopicAction_Override(s SnsTopicAction, topic awssns.ITopic, props *SnsTopicActionProps)

Experimental.

func NewSqsQueueAction_Override

func NewSqsQueueAction_Override(s SqsQueueAction, queue awssqs.IQueue, props *SqsQueueActionProps)

Experimental.

func NewStepFunctionsStateMachineAction_Override

func NewStepFunctionsStateMachineAction_Override(s StepFunctionsStateMachineAction, stateMachine awsstepfunctions.IStateMachine, props *StepFunctionsStateMachineActionProps)

Experimental.

Types

type CloudWatchLogsAction

type CloudWatchLogsAction interface {
	awscdkiotalpha.IAction
}

The action to send data to Amazon CloudWatch Logs.

Example:

import logs "github.com/aws/aws-cdk-go/awscdk"

logGroup := logs.NewLogGroup(this, jsii.String("MyLogGroup"))

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, timestamp() as timestamp FROM 'device/+/data'")),
	ErrorAction: actions.NewCloudWatchLogsAction(logGroup),
})

Experimental.

func NewCloudWatchLogsAction

func NewCloudWatchLogsAction(logGroup awslogs.ILogGroup, props *CloudWatchLogsActionProps) CloudWatchLogsAction

Experimental.

type CloudWatchLogsActionProps

type CloudWatchLogsActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
}

Configuration properties of an action for CloudWatch Logs.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import iot_actions_alpha "github.com/aws/aws-cdk-go/awscdkiotactionsalpha"
import "github.com/aws/aws-cdk-go/awscdk"

var role role

cloudWatchLogsActionProps := &CloudWatchLogsActionProps{
	Role: role,
}

Experimental.

type CloudWatchPutMetricAction

type CloudWatchPutMetricAction interface {
	awscdkiotalpha.IAction
}

The action to capture an Amazon CloudWatch metric.

Example:

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, namespace, unit, value, timestamp FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewCloudWatchPutMetricAction(&CloudWatchPutMetricActionProps{
			MetricName: jsii.String("${topic(2)}"),
			MetricNamespace: jsii.String("${namespace}"),
			MetricUnit: jsii.String("${unit}"),
			MetricValue: jsii.String("${value}"),
			MetricTimestamp: jsii.String("${timestamp}"),
		}),
	},
})

Experimental.

func NewCloudWatchPutMetricAction

func NewCloudWatchPutMetricAction(props *CloudWatchPutMetricActionProps) CloudWatchPutMetricAction

Experimental.

type CloudWatchPutMetricActionProps

type CloudWatchPutMetricActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// The CloudWatch metric name.
	//
	// Supports substitution templates.
	// See: https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html
	//
	// Experimental.
	MetricName *string `field:"required" json:"metricName" yaml:"metricName"`
	// The CloudWatch metric namespace name.
	//
	// Supports substitution templates.
	// See: https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html
	//
	// Experimental.
	MetricNamespace *string `field:"required" json:"metricNamespace" yaml:"metricNamespace"`
	// The metric unit supported by CloudWatch.
	//
	// Supports substitution templates.
	// See: https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html
	//
	// Experimental.
	MetricUnit *string `field:"required" json:"metricUnit" yaml:"metricUnit"`
	// A string that contains the CloudWatch metric value.
	//
	// Supports substitution templates.
	// See: https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html
	//
	// Experimental.
	MetricValue *string `field:"required" json:"metricValue" yaml:"metricValue"`
	// A string that contains the timestamp, expressed in seconds in Unix epoch time.
	//
	// Supports substitution templates.
	// See: https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html
	//
	// Default: - none -- Defaults to the current Unix epoch time.
	//
	// Experimental.
	MetricTimestamp *string `field:"optional" json:"metricTimestamp" yaml:"metricTimestamp"`
}

Configuration properties of an action for CloudWatch metric.

Example:

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, namespace, unit, value, timestamp FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewCloudWatchPutMetricAction(&CloudWatchPutMetricActionProps{
			MetricName: jsii.String("${topic(2)}"),
			MetricNamespace: jsii.String("${namespace}"),
			MetricUnit: jsii.String("${unit}"),
			MetricValue: jsii.String("${value}"),
			MetricTimestamp: jsii.String("${timestamp}"),
		}),
	},
})

Experimental.

type CloudWatchSetAlarmStateAction

type CloudWatchSetAlarmStateAction interface {
	awscdkiotalpha.IAction
}

The action to change the state of an Amazon CloudWatch alarm.

Example:

import "github.com/aws/aws-cdk-go/awscdk"

metric := cloudwatch.NewMetric(&MetricProps{
	Namespace: jsii.String("MyNamespace"),
	MetricName: jsii.String("MyMetric"),
	DimensionsMap: map[string]*string{
		"MyDimension": jsii.String("MyDimensionValue"),
	},
})
alarm := cloudwatch.NewAlarm(this, jsii.String("MyAlarm"), &AlarmProps{
	Metric: metric,
	Threshold: jsii.Number(100),
	EvaluationPeriods: jsii.Number(3),
	DatapointsToAlarm: jsii.Number(2),
})

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewCloudWatchSetAlarmStateAction(alarm, &CloudWatchSetAlarmStateActionProps{
			Reason: jsii.String("AWS Iot Rule action is triggered"),
			AlarmStateToSet: cloudwatch.AlarmState_ALARM,
		}),
	},
})

Experimental.

func NewCloudWatchSetAlarmStateAction

func NewCloudWatchSetAlarmStateAction(alarm awscloudwatch.IAlarm, props *CloudWatchSetAlarmStateActionProps) CloudWatchSetAlarmStateAction

Experimental.

type CloudWatchSetAlarmStateActionProps

type CloudWatchSetAlarmStateActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// The value of the alarm state to set.
	// Experimental.
	AlarmStateToSet awscloudwatch.AlarmState `field:"required" json:"alarmStateToSet" yaml:"alarmStateToSet"`
	// The reason for the alarm change.
	// Default: None.
	//
	// Experimental.
	Reason *string `field:"optional" json:"reason" yaml:"reason"`
}

Configuration properties of an action for CloudWatch alarm.

Example:

import "github.com/aws/aws-cdk-go/awscdk"

metric := cloudwatch.NewMetric(&MetricProps{
	Namespace: jsii.String("MyNamespace"),
	MetricName: jsii.String("MyMetric"),
	DimensionsMap: map[string]*string{
		"MyDimension": jsii.String("MyDimensionValue"),
	},
})
alarm := cloudwatch.NewAlarm(this, jsii.String("MyAlarm"), &AlarmProps{
	Metric: metric,
	Threshold: jsii.Number(100),
	EvaluationPeriods: jsii.Number(3),
	DatapointsToAlarm: jsii.Number(2),
})

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewCloudWatchSetAlarmStateAction(alarm, &CloudWatchSetAlarmStateActionProps{
			Reason: jsii.String("AWS Iot Rule action is triggered"),
			AlarmStateToSet: cloudwatch.AlarmState_ALARM,
		}),
	},
})

Experimental.

type CommonActionProps

type CommonActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
}

Common properties shared by Actions it access to AWS service.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import iot_actions_alpha "github.com/aws/aws-cdk-go/awscdkiotactionsalpha"
import "github.com/aws/aws-cdk-go/awscdk"

var role role

commonActionProps := &CommonActionProps{
	Role: role,
}

Experimental.

type DynamoDBv2PutItemAction

type DynamoDBv2PutItemAction interface {
	awscdkiotalpha.IAction
}

The action to put the record from an MQTT message to the DynamoDB table.

Example:

import dynamodb "github.com/aws/aws-cdk-go/awscdk"

var table table

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewDynamoDBv2PutItemAction(table),
	},
})

Experimental.

func NewDynamoDBv2PutItemAction

func NewDynamoDBv2PutItemAction(table awsdynamodb.ITable, props *DynamoDBv2PutItemActionProps) DynamoDBv2PutItemAction

Experimental.

type DynamoDBv2PutItemActionProps

type DynamoDBv2PutItemActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
}

Configuration properties of an action for the dynamodb table.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import iot_actions_alpha "github.com/aws/aws-cdk-go/awscdkiotactionsalpha"
import "github.com/aws/aws-cdk-go/awscdk"

var role role

dynamoDBv2PutItemActionProps := &DynamoDBv2PutItemActionProps{
	Role: role,
}

Experimental.

type FirehosePutRecordAction

type FirehosePutRecordAction interface {
	awscdkiotalpha.IAction
}

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

Example:

import firehose "github.com/aws/aws-cdk-go/awscdkkinesisfirehosealpha"
import destinations "github.com/aws/aws-cdk-go/awscdkkinesisfirehosedestinationsalpha"

bucket := s3.NewBucket(this, jsii.String("MyBucket"))
stream := firehose.NewDeliveryStream(this, jsii.String("MyStream"), &DeliveryStreamProps{
	Destinations: []iDestination{
		destinations.NewS3Bucket(bucket),
	},
})

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewFirehosePutRecordAction(stream, &FirehosePutRecordActionProps{
			BatchMode: jsii.Boolean(true),
			RecordSeparator: actions.FirehoseRecordSeparator_NEWLINE,
		}),
	},
})

Experimental.

func NewFirehosePutRecordAction

func NewFirehosePutRecordAction(stream awscdkkinesisfirehosealpha.IDeliveryStream, props *FirehosePutRecordActionProps) FirehosePutRecordAction

Experimental.

type FirehosePutRecordActionProps

type FirehosePutRecordActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// Whether to deliver the Kinesis Data Firehose stream as a batch by using `PutRecordBatch`.
	//
	// When batchMode is true and the rule's SQL statement evaluates to an Array, each Array
	// element forms one record in the PutRecordBatch request. The resulting array can't have
	// more than 500 records.
	// Default: false.
	//
	// Experimental.
	BatchMode *bool `field:"optional" json:"batchMode" yaml:"batchMode"`
	// A character separator that will be used to separate records written to the Kinesis Data Firehose stream.
	// Default: - none -- the stream does not use a separator.
	//
	// Experimental.
	RecordSeparator FirehoseRecordSeparator `field:"optional" json:"recordSeparator" yaml:"recordSeparator"`
}

Configuration properties of an action for the Kinesis Data Firehose stream.

Example:

import firehose "github.com/aws/aws-cdk-go/awscdkkinesisfirehosealpha"
import destinations "github.com/aws/aws-cdk-go/awscdkkinesisfirehosedestinationsalpha"

bucket := s3.NewBucket(this, jsii.String("MyBucket"))
stream := firehose.NewDeliveryStream(this, jsii.String("MyStream"), &DeliveryStreamProps{
	Destinations: []iDestination{
		destinations.NewS3Bucket(bucket),
	},
})

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewFirehosePutRecordAction(stream, &FirehosePutRecordActionProps{
			BatchMode: jsii.Boolean(true),
			RecordSeparator: actions.FirehoseRecordSeparator_NEWLINE,
		}),
	},
})

Experimental.

type FirehoseRecordSeparator

type FirehoseRecordSeparator string

Record Separator to be used to separate records.

Example:

import firehose "github.com/aws/aws-cdk-go/awscdkkinesisfirehosealpha"
import destinations "github.com/aws/aws-cdk-go/awscdkkinesisfirehosedestinationsalpha"

bucket := s3.NewBucket(this, jsii.String("MyBucket"))
stream := firehose.NewDeliveryStream(this, jsii.String("MyStream"), &DeliveryStreamProps{
	Destinations: []iDestination{
		destinations.NewS3Bucket(bucket),
	},
})

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewFirehosePutRecordAction(stream, &FirehosePutRecordActionProps{
			BatchMode: jsii.Boolean(true),
			RecordSeparator: actions.FirehoseRecordSeparator_NEWLINE,
		}),
	},
})

Experimental.

const (
	// Separate by a new line.
	// Experimental.
	FirehoseRecordSeparator_NEWLINE FirehoseRecordSeparator = "NEWLINE"
	// Separate by a tab.
	// Experimental.
	FirehoseRecordSeparator_TAB FirehoseRecordSeparator = "TAB"
	// Separate by a windows new line.
	// Experimental.
	FirehoseRecordSeparator_WINDOWS_NEWLINE FirehoseRecordSeparator = "WINDOWS_NEWLINE"
	// Separate by a commma.
	// Experimental.
	FirehoseRecordSeparator_COMMA FirehoseRecordSeparator = "COMMA"
)

type HttpActionHeader

type HttpActionHeader struct {
	// The HTTP header key.
	// Experimental.
	Key *string `field:"required" json:"key" yaml:"key"`
	// The HTTP header value.
	//
	// Substitution templates are supported.
	// Experimental.
	Value *string `field:"required" json:"value" yaml:"value"`
}

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import iot_actions_alpha "github.com/aws/aws-cdk-go/awscdkiotactionsalpha"

httpActionHeader := &HttpActionHeader{
	Key: jsii.String("key"),
	Value: jsii.String("value"),
}

Experimental.

type HttpActionSigV4Auth

type HttpActionSigV4Auth struct {
	// The service name.
	// Experimental.
	ServiceName *string `field:"required" json:"serviceName" yaml:"serviceName"`
	// The signing region.
	// Experimental.
	SigningRegion *string `field:"required" json:"signingRegion" yaml:"signingRegion"`
}

Example:

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
})

topicRule.AddAction(
actions.NewHttpsAction(jsii.String("https://example.com/endpoint"), &HttpsActionProps{
	ConfirmationUrl: jsii.String("https://example.com"),
	Headers: []httpActionHeader{
		&httpActionHeader{
			Key: jsii.String("key0"),
			Value: jsii.String("value0"),
		},
		&httpActionHeader{
			Key: jsii.String("key1"),
			Value: jsii.String("value1"),
		},
	},
	Auth: &HttpActionSigV4Auth{
		ServiceName: jsii.String("serviceName"),
		SigningRegion: jsii.String("us-east-1"),
	},
}))

Experimental.

type HttpsAction

type HttpsAction interface {
	awscdkiotalpha.IAction
}

The action to send data from an MQTT message to a web application or service.

Example:

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
})

topicRule.AddAction(
actions.NewHttpsAction(jsii.String("https://example.com/endpoint"), &HttpsActionProps{
	ConfirmationUrl: jsii.String("https://example.com"),
	Headers: []httpActionHeader{
		&httpActionHeader{
			Key: jsii.String("key0"),
			Value: jsii.String("value0"),
		},
		&httpActionHeader{
			Key: jsii.String("key1"),
			Value: jsii.String("value1"),
		},
	},
	Auth: &HttpActionSigV4Auth{
		ServiceName: jsii.String("serviceName"),
		SigningRegion: jsii.String("us-east-1"),
	},
}))

Experimental.

func NewHttpsAction

func NewHttpsAction(url *string, props *HttpsActionProps) HttpsAction

Experimental.

type HttpsActionProps

type HttpsActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// Use Sigv4 authorization.
	// Experimental.
	Auth *HttpActionSigV4Auth `field:"optional" json:"auth" yaml:"auth"`
	// If specified, AWS IoT uses the confirmation URL to create a matching topic rule destination.
	// Experimental.
	ConfirmationUrl *string `field:"optional" json:"confirmationUrl" yaml:"confirmationUrl"`
	// The headers to include in the HTTPS request to the endpoint.
	// Experimental.
	Headers *[]*HttpActionHeader `field:"optional" json:"headers" yaml:"headers"`
}

Configuration properties of an HTTPS action.

Example:

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
})

topicRule.AddAction(
actions.NewHttpsAction(jsii.String("https://example.com/endpoint"), &HttpsActionProps{
	ConfirmationUrl: jsii.String("https://example.com"),
	Headers: []httpActionHeader{
		&httpActionHeader{
			Key: jsii.String("key0"),
			Value: jsii.String("value0"),
		},
		&httpActionHeader{
			Key: jsii.String("key1"),
			Value: jsii.String("value1"),
		},
	},
	Auth: &HttpActionSigV4Auth{
		ServiceName: jsii.String("serviceName"),
		SigningRegion: jsii.String("us-east-1"),
	},
}))

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

Experimental.

type IotEventsPutMessageAction

type IotEventsPutMessageAction interface {
	awscdkiotalpha.IAction
}

The action to put the message from an MQTT message to the IoT Events input.

Example:

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,
		}),
	},
})

Experimental.

func NewIotEventsPutMessageAction

func NewIotEventsPutMessageAction(input awscdkioteventsalpha.IInput, props *IotEventsPutMessageActionProps) IotEventsPutMessageAction

Experimental.

type IotEventsPutMessageActionProps

type IotEventsPutMessageActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// Whether to process the event actions as a batch.
	//
	// When batchMode is true, you can't specify a messageId.
	//
	// When batchMode is true and the rule SQL statement evaluates to an Array,
	// each Array element is treated as a separate message when Events by calling BatchPutMessage.
	// The resulting array can't have more than 10 messages.
	// Default: false.
	//
	// Experimental.
	BatchMode *bool `field:"optional" json:"batchMode" yaml:"batchMode"`
	// The ID of the message.
	//
	// When batchMode is true, you can't specify a messageId--a new UUID value will be assigned.
	// Assign a value to this property to ensure that only one input (message) with a given messageId will be processed by an AWS IoT Events detector.
	// Default: - none -- a new UUID value will be assigned.
	//
	// Experimental.
	MessageId *string `field:"optional" json:"messageId" yaml:"messageId"`
}

Configuration properties of an action for the IoT Events.

Example:

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,
		}),
	},
})

Experimental.

type IotRepublishMqttAction

type IotRepublishMqttAction interface {
	awscdkiotalpha.IAction
}

The action to put the record from an MQTT message to republish another MQTT topic.

Example:

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewIotRepublishMqttAction(jsii.String("${topic()}/republish"), &IotRepublishMqttActionProps{
			QualityOfService: actions.MqttQualityOfService_AT_LEAST_ONCE,
		}),
	},
})

Experimental.

func NewIotRepublishMqttAction

func NewIotRepublishMqttAction(topic *string, props *IotRepublishMqttActionProps) IotRepublishMqttAction

Experimental.

type IotRepublishMqttActionProps

type IotRepublishMqttActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// The Quality of Service (QoS) level to use when republishing messages.
	// See: https://docs.aws.amazon.com/iot/latest/developerguide/mqtt.html#mqtt-qos
	//
	// Default: MqttQualityOfService.ZERO_OR_MORE_TIMES
	//
	// Experimental.
	QualityOfService MqttQualityOfService `field:"optional" json:"qualityOfService" yaml:"qualityOfService"`
}

Configuration properties of an action to republish MQTT messages.

Example:

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewIotRepublishMqttAction(jsii.String("${topic()}/republish"), &IotRepublishMqttActionProps{
			QualityOfService: actions.MqttQualityOfService_AT_LEAST_ONCE,
		}),
	},
})

Experimental.

type KinesisPutRecordAction

type KinesisPutRecordAction interface {
	awscdkiotalpha.IAction
}

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

Example:

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()}"),
		}),
	},
})

Experimental.

func NewKinesisPutRecordAction

func NewKinesisPutRecordAction(stream awskinesis.IStream, props *KinesisPutRecordActionProps) KinesisPutRecordAction

Experimental.

type KinesisPutRecordActionProps

type KinesisPutRecordActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// The partition key used to determine to which shard the data is written.
	//
	// The partition key is usually composed of an expression (for example, ${topic()} or ${timestamp()}).
	// See: https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html#API_PutRecord_RequestParameters
	//
	// Experimental.
	PartitionKey *string `field:"required" json:"partitionKey" yaml:"partitionKey"`
}

Configuration properties of an action for the Kinesis Data stream.

Example:

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()}"),
		}),
	},
})

Experimental.

type LambdaFunctionAction

type LambdaFunctionAction interface {
	awscdkiotalpha.IAction
}

The action to invoke an AWS Lambda function, passing in an MQTT message.

Example:

func := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromInline(jsii.String(`
	    exports.handler = (event) => {
	      console.log("It is test for lambda action of AWS IoT Rule.", event);
	    };`)),
})

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewLambdaFunctionAction(func),
	},
})

Experimental.

func NewLambdaFunctionAction

func NewLambdaFunctionAction(func_ awslambda.IFunction) LambdaFunctionAction

Experimental.

type MqttQualityOfService

type MqttQualityOfService string

MQTT Quality of Service (QoS) indicates the level of assurance for delivery of an MQTT Message.

Example:

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewIotRepublishMqttAction(jsii.String("${topic()}/republish"), &IotRepublishMqttActionProps{
			QualityOfService: actions.MqttQualityOfService_AT_LEAST_ONCE,
		}),
	},
})

See: https://docs.aws.amazon.com/iot/latest/developerguide/mqtt.html#mqtt-qos

Experimental.

const (
	// QoS level 0.
	//
	// Sent zero or more times.
	// This level should be used for messages that are sent over reliable communication links or that can be missed without a problem.
	// Experimental.
	MqttQualityOfService_ZERO_OR_MORE_TIMES MqttQualityOfService = "ZERO_OR_MORE_TIMES"
	// QoS level 1.
	//
	// Sent at least one time, and then repeatedly until a PUBACK response is received.
	// The message is not considered complete until the sender receives a PUBACK response to indicate successful delivery.
	// Experimental.
	MqttQualityOfService_AT_LEAST_ONCE MqttQualityOfService = "AT_LEAST_ONCE"
)

type OpenSearchAction

type OpenSearchAction interface {
	awscdkiotalpha.IAction
}

The action to write data to an Amazon OpenSearch Service domain.

Example:

import opensearch "github.com/aws/aws-cdk-go/awscdk"
var domain domain

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
})

topicRule.AddAction(actions.NewOpenSearchAction(domain, &OpenSearchActionProps{
	Id: jsii.String("my-id"),
	Index: jsii.String("my-index"),
	Type: jsii.String("my-type"),
}))

Experimental.

func NewOpenSearchAction

func NewOpenSearchAction(domain awsopensearchservice.Domain, props *OpenSearchActionProps) OpenSearchAction

Experimental.

type OpenSearchActionProps

type OpenSearchActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// The unique identifier for the document you are storing.
	// Experimental.
	Id *string `field:"required" json:"id" yaml:"id"`
	// The OpenSearch index where you want to store your data.
	// Experimental.
	Index *string `field:"required" json:"index" yaml:"index"`
	// The type of document you are storing.
	// Experimental.
	Type *string `field:"required" json:"type" yaml:"type"`
}

Configuration properties of an action for Open Search.

Example:

import opensearch "github.com/aws/aws-cdk-go/awscdk"
var domain domain

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
})

topicRule.AddAction(actions.NewOpenSearchAction(domain, &OpenSearchActionProps{
	Id: jsii.String("my-id"),
	Index: jsii.String("my-index"),
	Type: jsii.String("my-type"),
}))

Experimental.

type S3PutObjectAction

type S3PutObjectAction interface {
	awscdkiotalpha.IAction
}

The action to write the data from an MQTT message to an Amazon S3 bucket.

Example:

bucket := s3.NewBucket(this, jsii.String("MyBucket"))

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewS3PutObjectAction(bucket, &S3PutObjectActionProps{
			Key: jsii.String("${year}/${month}/${day}/${topic(2)}"),
		}),
	},
})

Experimental.

func NewS3PutObjectAction

func NewS3PutObjectAction(bucket awss3.IBucket, props *S3PutObjectActionProps) S3PutObjectAction

Experimental.

type S3PutObjectActionProps

type S3PutObjectActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// The Amazon S3 canned ACL that controls access to the object identified by the object key.
	// See: https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
	//
	// Default: None.
	//
	// Experimental.
	AccessControl awss3.BucketAccessControl `field:"optional" json:"accessControl" yaml:"accessControl"`
	// The path to the file where the data is written.
	//
	// Supports substitution templates.
	// See: https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html
	//
	// Default: '${topic()}/${timestamp()}'.
	//
	// Experimental.
	Key *string `field:"optional" json:"key" yaml:"key"`
}

Configuration properties of an action for s3.

Example:

bucket := s3.NewBucket(this, jsii.String("MyBucket"))

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewS3PutObjectAction(bucket, &S3PutObjectActionProps{
			Key: jsii.String("${year}/${month}/${day}/${topic(2)}"),
		}),
	},
})

Experimental.

type SnsActionMessageFormat

type SnsActionMessageFormat string

SNS topic action message format options.

Example:

import sns "github.com/aws/aws-cdk-go/awscdk"

topic := sns.NewTopic(this, jsii.String("MyTopic"))

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewSnsTopicAction(topic, &SnsTopicActionProps{
			MessageFormat: actions.SnsActionMessageFormat_JSON,
		}),
	},
})

Experimental.

const (
	// RAW message format.
	// Experimental.
	SnsActionMessageFormat_RAW SnsActionMessageFormat = "RAW"
	// JSON message format.
	// Experimental.
	SnsActionMessageFormat_JSON SnsActionMessageFormat = "JSON"
)

type SnsTopicAction

type SnsTopicAction interface {
	awscdkiotalpha.IAction
}

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

Example:

import sns "github.com/aws/aws-cdk-go/awscdk"

topic := sns.NewTopic(this, jsii.String("MyTopic"))

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewSnsTopicAction(topic, &SnsTopicActionProps{
			MessageFormat: actions.SnsActionMessageFormat_JSON,
		}),
	},
})

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

Experimental.

func NewSnsTopicAction

func NewSnsTopicAction(topic awssns.ITopic, props *SnsTopicActionProps) SnsTopicAction

Experimental.

type SnsTopicActionProps

type SnsTopicActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// The message format of the message to publish.
	//
	// SNS uses this setting to determine if the payload should be parsed and relevant platform-specific bits of the payload should be extracted.
	// See: https://docs.aws.amazon.com/sns/latest/dg/sns-message-and-json-formats.html
	//
	// Default: SnsActionMessageFormat.RAW
	//
	// Experimental.
	MessageFormat SnsActionMessageFormat `field:"optional" json:"messageFormat" yaml:"messageFormat"`
}

Configuration options for the SNS topic action.

Example:

import sns "github.com/aws/aws-cdk-go/awscdk"

topic := sns.NewTopic(this, jsii.String("MyTopic"))

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewSnsTopicAction(topic, &SnsTopicActionProps{
			MessageFormat: actions.SnsActionMessageFormat_JSON,
		}),
	},
})

Experimental.

type SqsQueueAction

type SqsQueueAction interface {
	awscdkiotalpha.IAction
}

The action to write the data from an MQTT message to an Amazon SQS queue.

Example:

import sqs "github.com/aws/aws-cdk-go/awscdk"

queue := sqs.NewQueue(this, jsii.String("MyQueue"))

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewSqsQueueAction(queue, &SqsQueueActionProps{
			UseBase64: jsii.Boolean(true),
		}),
	},
})

Experimental.

func NewSqsQueueAction

func NewSqsQueueAction(queue awssqs.IQueue, props *SqsQueueActionProps) SqsQueueAction

Experimental.

type SqsQueueActionProps

type SqsQueueActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// Specifies whether to use Base64 encoding.
	// Default: false.
	//
	// Experimental.
	UseBase64 *bool `field:"optional" json:"useBase64" yaml:"useBase64"`
}

Configuration properties of an action for SQS.

Example:

import sqs "github.com/aws/aws-cdk-go/awscdk"

queue := sqs.NewQueue(this, jsii.String("MyQueue"))

topicRule := iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewSqsQueueAction(queue, &SqsQueueActionProps{
			UseBase64: jsii.Boolean(true),
		}),
	},
})

Experimental.

type StepFunctionsStateMachineAction

type StepFunctionsStateMachineAction interface {
	awscdkiotalpha.IAction
}

The action to put the record from an MQTT message to the Step Functions State Machine.

Example:

stateMachine := stepfunctions.NewStateMachine(this, jsii.String("SM"), &StateMachineProps{
	DefinitionBody: stepfunctions.DefinitionBody_FromChainable(stepfunctions.NewWait(this, jsii.String("Hello"), &WaitProps{
		Time: stepfunctions.WaitTime_Duration(awscdk.Duration_Seconds(jsii.Number(10))),
	})),
})

iot.NewTopicRule(this, jsii.String("TopicRule"), &TopicRuleProps{
	Sql: iot.IotSql_FromStringAsVer20160323(jsii.String("SELECT * FROM 'device/+/data'")),
	Actions: []iAction{
		actions.NewStepFunctionsStateMachineAction(stateMachine),
	},
})

Experimental.

func NewStepFunctionsStateMachineAction

func NewStepFunctionsStateMachineAction(stateMachine awsstepfunctions.IStateMachine, props *StepFunctionsStateMachineActionProps) StepFunctionsStateMachineAction

Experimental.

type StepFunctionsStateMachineActionProps

type StepFunctionsStateMachineActionProps struct {
	// The IAM role that allows access to AWS service.
	// Default: a new role will be created.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// Name of the state machine execution prefix.
	//
	// The name given to the state machine execution consists of this prefix followed by a UUID. Step Functions creates a unique name for each state machine execution if one is not provided.
	// See: https://docs.aws.amazon.com/iot/latest/developerguide/stepfunctions-rule-action.html#stepfunctions-rule-action-parameters
	//
	// Default: : None - Step Functions creates a unique name for each state machine execution if one is not provided.
	//
	// Experimental.
	ExecutionNamePrefix *string `field:"optional" json:"executionNamePrefix" yaml:"executionNamePrefix"`
}

Configuration properties of an action for the Step Functions State Machine.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import iot_actions_alpha "github.com/aws/aws-cdk-go/awscdkiotactionsalpha"
import "github.com/aws/aws-cdk-go/awscdk"

var role role

stepFunctionsStateMachineActionProps := &StepFunctionsStateMachineActionProps{
	ExecutionNamePrefix: jsii.String("executionNamePrefix"),
	Role: role,
}

Experimental.

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL