Receipt rule actions for AWS IoT
Project description
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/aws-iot
.
Currently supported are:
- Invoke a Lambda function
Invoke a Lambda function
The code snippet below creates an AWS IoT Rule that invoke a Lambda function when it is triggered.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_iot as iot
import aws_cdk.aws_iot_actions as actions
import aws_cdk.aws_lambda as lambda_
func = lambda_.Function(self, "MyFunction",
runtime=lambda_.Runtime.NODEJS_14_X,
handler="index.handler",
code=lambda_.Code.from_inline("""
exports.handler = (event) => {
console.log("It is test for lambda action of AWS IoT Rule.", event);
};""")
)
iot.TopicRule(self, "TopicRule",
sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'"),
actions=[actions.LambdaFunctionAction(func)]
)
Put logs to CloudWatch Logs
The code snippet below creates an AWS IoT Rule that put logs to CloudWatch Logs when it is triggered.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_iot as iot
import aws_cdk.aws_iot_actions as actions
import aws_cdk.aws_logs as logs
log_group = logs.LogGroup(self, "MyLogGroup")
iot.TopicRule(self, "TopicRule",
sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id FROM 'device/+/data'"),
actions=[actions.CloudWatchLogsAction(log_group)]
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-iot-actions-alpha-2.0.0a7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 917c27a3a05a81a098c0146c570cb1bc33d635ee55f56bc787ce12f6f6dec6a1 |
|
MD5 | 969fe1de48750ba3acc165091d355796 |
|
BLAKE2b-256 | e748428b22667002d7b800853840c2785cca8ad8e07b6118f1e3e5fdb1c7829b |
Hashes for aws_cdk.aws_iot_actions_alpha-2.0.0a7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b88ccaf5cb8de5c7c799cf8ab2e6fbacd6e22655c09d0d38adf37a9b627b0f3 |
|
MD5 | 612ae4a8ea091dcaeb8ae8fd9d4d9530 |
|
BLAKE2b-256 | efc5e3984afd82a12800077672276a1571fed0b7b3e6f5bb611589c592736204 |