aws-cdk.aws-iot-actions-alpha


Nameaws-cdk.aws-iot-actions-alpha JSON
Version 2.170.0a0 PyPI version JSON
download
home_pagehttps://github.com/aws/aws-cdk
SummaryReceipt rule actions for AWS IoT
upload_time2024-11-22 04:42:21
maintainerNone
docs_urlNone
authorAmazon Web Services
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Actions for AWS IoT Rule

<!--BEGIN STABILITY BANNER-->---


![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> 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](https://semver.org/) 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.

---
<!--END STABILITY BANNER-->

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.

```python
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.IotRepublishMqttAction("${topic()}/republish",
            quality_of_service=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.

```python
func = lambda_.Function(self, "MyFunction",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    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 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.

```python
bucket = s3.Bucket(self, "MyBucket")

iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id FROM 'device/+/data'"),
    actions=[actions.S3PutObjectAction(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](https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html).
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:

```python
bucket = s3.Bucket(self, "MyBucket")

iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'"),
    actions=[
        actions.S3PutObjectAction(bucket,
            key="${year}/${month}/${day}/${topic(2)}"
        )
    ]
)
```

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

```python
bucket = s3.Bucket(self, "MyBucket")

iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT * FROM 'device/+/data'"),
    actions=[
        actions.S3PutObjectAction(bucket,
            access_control=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.

```python
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)]
)
```

## Capture CloudWatch metrics

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

```python
topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id, namespace, unit, value, timestamp FROM 'device/+/data'"),
    actions=[
        actions.CloudWatchPutMetricAction(
            metric_name="${topic(2)}",
            metric_namespace="${namespace}",
            metric_unit="${unit}",
            metric_value="${value}",
            metric_timestamp="${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.

```python
state_machine = stepfunctions.StateMachine(self, "SM",
    definition_body=stepfunctions.DefinitionBody.from_chainable(stepfunctions.Wait(self, "Hello", time=stepfunctions.WaitTime.duration(Duration.seconds(10))))
)

iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT * FROM 'device/+/data'"),
    actions=[
        actions.StepFunctionsStateMachineAction(state_machine)
    ]
)
```

## 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:

```python
import aws_cdk.aws_cloudwatch as cloudwatch


metric = cloudwatch.Metric(
    namespace="MyNamespace",
    metric_name="MyMetric",
    dimensions_map={"MyDimension": "MyDimensionValue"}
)
alarm = cloudwatch.Alarm(self, "MyAlarm",
    metric=metric,
    threshold=100,
    evaluation_periods=3,
    datapoints_to_alarm=2
)

topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id FROM 'device/+/data'"),
    actions=[
        actions.CloudWatchSetAlarmStateAction(alarm,
            reason="AWS Iot Rule action is triggered",
            alarm_state_to_set=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.

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

## 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.

```python
import aws_cdk.aws_kinesisfirehose_alpha as firehose
import aws_cdk.aws_kinesisfirehose_destinations_alpha as destinations


bucket = s3.Bucket(self, "MyBucket")
stream = firehose.DeliveryStream(self, "MyStream",
    destination=destinations.S3Bucket(bucket)
)

topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT * FROM 'device/+/data'"),
    actions=[
        actions.FirehosePutRecordAction(stream,
            batch_mode=True,
            record_separator=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:

```python
import aws_cdk.aws_sqs as sqs


queue = sqs.Queue(self, "MyQueue")

topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'"),
    actions=[
        actions.SqsQueueAction(queue,
            use_base64=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:

```python
import aws_cdk.aws_sns as sns


topic = sns.Topic(self, "MyTopic")

topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'"),
    actions=[
        actions.SnsTopicAction(topic,
            message_format=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.

```python
import aws_cdk.aws_dynamodb as dynamodb

# table: dynamodb.Table


topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT * FROM 'device/+/data'"),
    actions=[
        actions.DynamoDBv2PutItemAction(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:

```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
        )
    ]
)
```

## 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:

```python
topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")
)

topic_rule.add_action(
    actions.HttpsAction("https://example.com/endpoint",
        confirmation_url="https://example.com",
        headers=[actions.HttpActionHeader(key="key0", value="value0"), actions.HttpActionHeader(key="key1", value="value1")
        ],
        auth=actions.HttpActionSigV4Auth(service_name="serviceName", signing_region="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:

```python
import aws_cdk.aws_opensearchservice as opensearch
# domain: opensearch.Domain


topic_rule = iot.TopicRule(self, "TopicRule",
    sql=iot.IotSql.from_string_as_ver20160323("SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'")
)

topic_rule.add_action(actions.OpenSearchAction(domain,
    id="my-id",
    index="my-index",
    type="my-type"
))
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aws/aws-cdk",
    "name": "aws-cdk.aws-iot-actions-alpha",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Amazon Web Services",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/f4/17/99cf3e8e117bbbab87b27371c826f64d4e00942916f288002e482da125a1/aws_cdk_aws_iot_actions_alpha-2.170.0a0.tar.gz",
    "platform": null,
    "description": "# Actions for AWS IoT Rule\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n<!--END STABILITY BANNER-->\n\nThis library contains integration classes to send data to any number of\nsupported AWS Services. Instances of these classes should be passed to\n`TopicRule` defined in `aws-cdk-lib/aws-iot`.\n\nCurrently supported are:\n\n* Republish a message to another MQTT topic\n* Invoke a Lambda function\n* Put objects to a S3 bucket\n* Put logs to CloudWatch Logs\n* Capture CloudWatch metrics\n* Change state for a CloudWatch alarm\n* Put records to Kinesis Data stream\n* Put records to Kinesis Data Firehose stream\n* Send messages to SQS queues\n* Publish messages on SNS topics\n* Write messages into columns of DynamoDB\n* Put messages IoT Events input\n* Send messages to HTTPS endpoints\n\n## Republish a message to another MQTT topic\n\nThe code snippet below creates an AWS IoT Rule that republish a message to\nanother MQTT topic when it is triggered.\n\n```python\niot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'\"),\n    actions=[\n        actions.IotRepublishMqttAction(\"${topic()}/republish\",\n            quality_of_service=actions.MqttQualityOfService.AT_LEAST_ONCE\n        )\n    ]\n)\n```\n\n## Invoke a Lambda function\n\nThe code snippet below creates an AWS IoT Rule that invoke a Lambda function\nwhen it is triggered.\n\n```python\nfunc = lambda_.Function(self, \"MyFunction\",\n    runtime=lambda_.Runtime.NODEJS_LATEST,\n    handler=\"index.handler\",\n    code=lambda_.Code.from_inline(\"\"\"\n            exports.handler = (event) => {\n              console.log(\"It is test for lambda action of AWS IoT Rule.\", event);\n            };\"\"\")\n)\n\niot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id, timestamp() as timestamp, temperature FROM 'device/+/data'\"),\n    actions=[actions.LambdaFunctionAction(func)]\n)\n```\n\n## Put objects to a S3 bucket\n\nThe code snippet below creates an AWS IoT Rule that puts objects to a S3 bucket\nwhen it is triggered.\n\n```python\nbucket = s3.Bucket(self, \"MyBucket\")\n\niot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id FROM 'device/+/data'\"),\n    actions=[actions.S3PutObjectAction(bucket)]\n)\n```\n\nThe property `key` of `S3PutObjectAction` is given the value `${topic()}/${timestamp()}` by default. This `${topic()}`\nand `${timestamp()}` is called Substitution templates. For more information see\n[this documentation](https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html).\nIn above sample, `${topic()}` is replaced by a given MQTT topic as `device/001/data`. And `${timestamp()}` is replaced\nby the number of the current timestamp in milliseconds as `1636289461203`. So if the MQTT broker receives an MQTT topic\n`device/001/data` on `2021-11-07T00:00:00.000Z`, the S3 bucket object will be put to `device/001/data/1636243200000`.\n\nYou can also set specific `key` as following:\n\n```python\nbucket = s3.Bucket(self, \"MyBucket\")\n\niot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'\"),\n    actions=[\n        actions.S3PutObjectAction(bucket,\n            key=\"${year}/${month}/${day}/${topic(2)}\"\n        )\n    ]\n)\n```\n\nIf you wanna set access control to the S3 bucket object, you can specify `accessControl` as following:\n\n```python\nbucket = s3.Bucket(self, \"MyBucket\")\n\niot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT * FROM 'device/+/data'\"),\n    actions=[\n        actions.S3PutObjectAction(bucket,\n            access_control=s3.BucketAccessControl.PUBLIC_READ\n        )\n    ]\n)\n```\n\n## Put logs to CloudWatch Logs\n\nThe code snippet below creates an AWS IoT Rule that puts logs to CloudWatch Logs\nwhen it is triggered.\n\n```python\nimport aws_cdk.aws_logs as logs\n\n\nlog_group = logs.LogGroup(self, \"MyLogGroup\")\n\niot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id FROM 'device/+/data'\"),\n    actions=[actions.CloudWatchLogsAction(log_group)]\n)\n```\n\n## Capture CloudWatch metrics\n\nThe code snippet below creates an AWS IoT Rule that capture CloudWatch metrics\nwhen it is triggered.\n\n```python\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id, namespace, unit, value, timestamp FROM 'device/+/data'\"),\n    actions=[\n        actions.CloudWatchPutMetricAction(\n            metric_name=\"${topic(2)}\",\n            metric_namespace=\"${namespace}\",\n            metric_unit=\"${unit}\",\n            metric_value=\"${value}\",\n            metric_timestamp=\"${timestamp}\"\n        )\n    ]\n)\n```\n\n## Start Step Functions State Machine\n\nThe code snippet below creates an AWS IoT Rule that starts a Step Functions State Machine\nwhen it is triggered.\n\n```python\nstate_machine = stepfunctions.StateMachine(self, \"SM\",\n    definition_body=stepfunctions.DefinitionBody.from_chainable(stepfunctions.Wait(self, \"Hello\", time=stepfunctions.WaitTime.duration(Duration.seconds(10))))\n)\n\niot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT * FROM 'device/+/data'\"),\n    actions=[\n        actions.StepFunctionsStateMachineAction(state_machine)\n    ]\n)\n```\n\n## Change the state of an Amazon CloudWatch alarm\n\nThe code snippet below creates an AWS IoT Rule that changes the state of an Amazon CloudWatch alarm when it is triggered:\n\n```python\nimport aws_cdk.aws_cloudwatch as cloudwatch\n\n\nmetric = cloudwatch.Metric(\n    namespace=\"MyNamespace\",\n    metric_name=\"MyMetric\",\n    dimensions_map={\"MyDimension\": \"MyDimensionValue\"}\n)\nalarm = cloudwatch.Alarm(self, \"MyAlarm\",\n    metric=metric,\n    threshold=100,\n    evaluation_periods=3,\n    datapoints_to_alarm=2\n)\n\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id FROM 'device/+/data'\"),\n    actions=[\n        actions.CloudWatchSetAlarmStateAction(alarm,\n            reason=\"AWS Iot Rule action is triggered\",\n            alarm_state_to_set=cloudwatch.AlarmState.ALARM\n        )\n    ]\n)\n```\n\n## Put records to Kinesis Data stream\n\nThe code snippet below creates an AWS IoT Rule that puts records to Kinesis Data\nstream when it is triggered.\n\n```python\nimport aws_cdk.aws_kinesis as kinesis\n\n\nstream = kinesis.Stream(self, \"MyStream\")\n\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT * FROM 'device/+/data'\"),\n    actions=[\n        actions.KinesisPutRecordAction(stream,\n            partition_key=\"${newuuid()}\"\n        )\n    ]\n)\n```\n\n## Put records to Kinesis Data Firehose stream\n\nThe code snippet below creates an AWS IoT Rule that puts records to Put records\nto Kinesis Data Firehose stream when it is triggered.\n\n```python\nimport aws_cdk.aws_kinesisfirehose_alpha as firehose\nimport aws_cdk.aws_kinesisfirehose_destinations_alpha as destinations\n\n\nbucket = s3.Bucket(self, \"MyBucket\")\nstream = firehose.DeliveryStream(self, \"MyStream\",\n    destination=destinations.S3Bucket(bucket)\n)\n\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT * FROM 'device/+/data'\"),\n    actions=[\n        actions.FirehosePutRecordAction(stream,\n            batch_mode=True,\n            record_separator=actions.FirehoseRecordSeparator.NEWLINE\n        )\n    ]\n)\n```\n\n## Send messages to an SQS queue\n\nThe code snippet below creates an AWS IoT Rule that send messages\nto an SQS queue when it is triggered:\n\n```python\nimport aws_cdk.aws_sqs as sqs\n\n\nqueue = sqs.Queue(self, \"MyQueue\")\n\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'\"),\n    actions=[\n        actions.SqsQueueAction(queue,\n            use_base64=True\n        )\n    ]\n)\n```\n\n## Publish messages on an SNS topic\n\nThe code snippet below creates and AWS IoT Rule that publishes messages to an SNS topic when it is triggered:\n\n```python\nimport aws_cdk.aws_sns as sns\n\n\ntopic = sns.Topic(self, \"MyTopic\")\n\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'\"),\n    actions=[\n        actions.SnsTopicAction(topic,\n            message_format=actions.SnsActionMessageFormat.JSON\n        )\n    ]\n)\n```\n\n## Write attributes of a message to DynamoDB\n\nThe code snippet below creates an AWS IoT rule that writes all or part of an\nMQTT message to DynamoDB using the DynamoDBv2 action.\n\n```python\nimport aws_cdk.aws_dynamodb as dynamodb\n\n# table: dynamodb.Table\n\n\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT * FROM 'device/+/data'\"),\n    actions=[\n        actions.DynamoDBv2PutItemAction(table)\n    ]\n)\n```\n\n## Put messages IoT Events input\n\nThe code snippet below creates an AWS IoT Rule that puts messages\nto an IoT Events input when it is triggered:\n\n```python\nimport aws_cdk.aws_iotevents_alpha as iotevents\nimport aws_cdk.aws_iam as iam\n\n# role: iam.IRole\n\n\ninput = iotevents.Input(self, \"MyInput\",\n    attribute_json_paths=[\"payload.temperature\", \"payload.transactionId\"]\n)\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT * FROM 'device/+/data'\"),\n    actions=[\n        actions.IotEventsPutMessageAction(input,\n            batch_mode=True,  # optional property, default is 'false'\n            message_id=\"${payload.transactionId}\",  # optional property, default is a new UUID\n            role=role\n        )\n    ]\n)\n```\n\n## Send Messages to HTTPS Endpoints\n\nThe code snippet below creates an AWS IoT Rule that sends messages\nto an HTTPS endpoint when it is triggered:\n\n```python\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'\")\n)\n\ntopic_rule.add_action(\n    actions.HttpsAction(\"https://example.com/endpoint\",\n        confirmation_url=\"https://example.com\",\n        headers=[actions.HttpActionHeader(key=\"key0\", value=\"value0\"), actions.HttpActionHeader(key=\"key1\", value=\"value1\")\n        ],\n        auth=actions.HttpActionSigV4Auth(service_name=\"serviceName\", signing_region=\"us-east-1\")\n    ))\n```\n\n## Write Data to Open Search Service\n\nThe code snippet below creates an AWS IoT Rule that writes data\nto an Open Search Service when it is triggered:\n\n```python\nimport aws_cdk.aws_opensearchservice as opensearch\n# domain: opensearch.Domain\n\n\ntopic_rule = iot.TopicRule(self, \"TopicRule\",\n    sql=iot.IotSql.from_string_as_ver20160323(\"SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'\")\n)\n\ntopic_rule.add_action(actions.OpenSearchAction(domain,\n    id=\"my-id\",\n    index=\"my-index\",\n    type=\"my-type\"\n))\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Receipt rule actions for AWS IoT",
    "version": "2.170.0a0",
    "project_urls": {
        "Homepage": "https://github.com/aws/aws-cdk",
        "Source": "https://github.com/aws/aws-cdk.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff496a63a64cd187e2cc0d2ee130da3965bd9f023760b238f2b52551114724e3",
                "md5": "2076a40323e5313756c712a8762071ad",
                "sha256": "d10ffc82b2322bab3d0d656ffba5ea0292597ed4a673aaabb6a24e5e1382a647"
            },
            "downloads": -1,
            "filename": "aws_cdk.aws_iot_actions_alpha-2.170.0a0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2076a40323e5313756c712a8762071ad",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 113553,
            "upload_time": "2024-11-22T04:41:33",
            "upload_time_iso_8601": "2024-11-22T04:41:33.203845Z",
            "url": "https://files.pythonhosted.org/packages/ff/49/6a63a64cd187e2cc0d2ee130da3965bd9f023760b238f2b52551114724e3/aws_cdk.aws_iot_actions_alpha-2.170.0a0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f41799cf3e8e117bbbab87b27371c826f64d4e00942916f288002e482da125a1",
                "md5": "0636966203bbc10053353ab26fd64315",
                "sha256": "b2babf5a39741b76aeb4c05a57f344614e3e244105f4e108ae43f79fea832be6"
            },
            "downloads": -1,
            "filename": "aws_cdk_aws_iot_actions_alpha-2.170.0a0.tar.gz",
            "has_sig": false,
            "md5_digest": "0636966203bbc10053353ab26fd64315",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 114398,
            "upload_time": "2024-11-22T04:42:21",
            "upload_time_iso_8601": "2024-11-22T04:42:21.460744Z",
            "url": "https://files.pythonhosted.org/packages/f4/17/99cf3e8e117bbbab87b27371c826f64d4e00942916f288002e482da125a1/aws_cdk_aws_iot_actions_alpha-2.170.0a0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-22 04:42:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aws",
    "github_project": "aws-cdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aws-cdk.aws-iot-actions-alpha"
}
        
Elapsed time: 1.21614s