This release is a pre-release and may not be stable for production use.
Actions for AWS::IoTEvents Detector Model
---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 specify actions of state events of Detector Model in @aws-cdk/aws-iotevents-alpha.
Instances of these classes should be passed to State defined in @aws-cdk/aws-iotevents-alpha
You can define built-in actions to use a timer or set a variable, or send data to other AWS resources.
This library contains integration classes to use a timer or set a variable, or send data to other AWS resources. AWS IoT Events can trigger actions when it detects a specified event or transition event.
Currently supported are:
- Use timer
- Set variable to detector instance
- Invoke a Lambda function
Use timer
The code snippet below creates an Action that creates the timer with duration in seconds.
# Example automatically generated from non-compiling source. May contain errors.
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iotevents_actions_alpha as actions
# input: iotevents.IInput
state = iotevents.State(
state_name="MyState",
on_enter=[iotevents.Event(
event_name="test-event",
condition=iotevents.Expression.current_input(input),
actions=[
actions.SetTimerAction("MyTimer", {
"duration": cdk.Duration.seconds(60)
})
]
)]
)
Setting duration by IoT Events Expression:
# Example automatically generated from non-compiling source. May contain errors.
actions.SetTimerAction("MyTimer",
duration_expression=iotevents.Expression.input_attribute(input, "payload.durationSeconds")
)
And the timer can be reset and cleared. Below is an example of general Device HeartBeat Detector Model:
# Example automatically generated from non-compiling source. May contain errors.
online = iotevents.State(
state_name="Online",
on_enter=[{
"event_name": "enter-event",
"condition": iotevents.Expression.current_input(input),
"actions": [
actions.SetTimerAction("MyTimer",
duration=cdk.Duration.seconds(60)
)
]
}],
on_input=[{
"event_name": "input-event",
"condition": iotevents.Expression.current_input(input),
"actions": [
actions.ResetTimerAction("MyTimer")
]
}],
on_exit=[{
"event_name": "exit-event",
"actions": [
actions.ClearTimerAction("MyTimer")
]
}]
)
offline = iotevents.State(state_name="Offline")
online.transition_to(offline, when=iotevents.Expression.timeout("MyTimer"))
offline.transition_to(online, when=iotevents.Expression.current_input(input))
Set variable to detector instance
The code snippet below creates an Action that set variable to detector instance when it is triggered.
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iotevents_actions_alpha as actions
# input: iotevents.IInput
state = iotevents.State(
state_name="MyState",
on_enter=[iotevents.Event(
event_name="test-event",
condition=iotevents.Expression.current_input(input),
actions=[
actions.SetVariableAction("MyVariable",
iotevents.Expression.input_attribute(input, "payload.temperature"))
]
)]
)
Invoke a Lambda function
The code snippet below creates an Action that invoke a Lambda function when it is triggered.
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iotevents_actions_alpha as actions
import aws_cdk.aws_lambda as lambda_
# input: iotevents.IInput
# func: lambda.IFunction
state = iotevents.State(
state_name="MyState",
on_enter=[iotevents.Event(
event_name="test-event",
condition=iotevents.Expression.current_input(input),
actions=[actions.LambdaInvokeAction(func)]
)]
)
Release files for aws-cdk.aws-iotevents-actions-alpha 2.265.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aws_cdk_aws_iotevents_actions_alpha-2.265.0a0.tar.gz | 55.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aws_cdk_aws_iotevents_actions_alpha-2.265.0a0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 108.7 kB
Release files / aws_cdk_aws_iotevents_actions_alpha-2.265.0a0.tar.gz
| Download URL | aws_cdk_aws_iotevents_actions_alpha-2.265.0a0.tar.gz |
|---|---|
| Size | 55.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c55f5df7487dba79043eee8f734d9b331385b64b78ec8288b326e473d1a0410
|
|
BLAKE2b-256 checksum How to use checksums |
689dd0093d825ef66c0d7ae89878e6539e4ea90737f6cced4d380b01605c924b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Release files / aws_cdk_aws_iotevents_actions_alpha-2.265.0a0-py3-none-any.whl
| Download URL | aws_cdk_aws_iotevents_actions_alpha-2.265.0a0-py3-none-any.whl |
|---|---|
| Size | 53.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd06d269135ec48ca99e0a8b67dec230cc535696cfd9c76f723721f0afda56ae
|
|
BLAKE2b-256 checksum How to use checksums |
98aadcbddfeb974c8efa6b2b4d53fba0bf110e7898c16050e71d0d5e6dbb9cd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|