2.141.0-alpha.0 • Published 3 days ago

@aws-cdk/aws-iotevents-actions-alpha v2.141.0-alpha.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 days ago

Actions for AWS::IoTEvents Detector Model


cdk-constructs: Experimental

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.

import * as iotevents from '@aws-cdk/aws-iotevents-alpha';
import * as actions from '@aws-cdk/aws-iotevents-actions-alpha';

declare const input: iotevents.IInput;

const state = new iotevents.State({
  stateName: 'MyState',
  onEnter: [{
    eventName: 'test-event',
    condition: iotevents.Expression.currentInput(input),
    actions: [
      new actions.SetTimerAction('MyTimer', {
        duration: cdk.Duration.seconds(60),
      }),
    ],
  }],
});

Setting duration by IoT Events Expression:

new actions.SetTimerAction('MyTimer', {
  durationExpression: iotevents.Expression.inputAttribute(input, 'payload.durationSeconds'),
})

And the timer can be reset and cleared. Below is an example of general Device HeartBeat Detector Model:

const online = new iotevents.State({
  stateName: 'Online',
  onEnter: [{
    eventName: 'enter-event',
    condition: iotevents.Expression.currentInput(input),
    actions: [
      new actions.SetTimerAction('MyTimer', {
        duration: cdk.Duration.seconds(60),
      }),
    ],
  }],
  onInput: [{
    eventName: 'input-event',
    condition: iotevents.Expression.currentInput(input),
    actions: [
      new actions.ResetTimerAction('MyTimer'),
    ],
  }],
  onExit: [{
    eventName: 'exit-event',
    actions: [
      new actions.ClearTimerAction('MyTimer'),
    ],
  }],
});
const offline = new iotevents.State({ stateName: 'Offline' });

online.transitionTo(offline, { when: iotevents.Expression.timeout('MyTimer') });
offline.transitionTo(online, { when: iotevents.Expression.currentInput(input) });

Set variable to detector instance

The code snippet below creates an Action that set variable to detector instance when it is triggered.

import * as iotevents from '@aws-cdk/aws-iotevents-alpha';
import * as actions from '@aws-cdk/aws-iotevents-actions-alpha';

declare const input: iotevents.IInput;

const state = new iotevents.State({
  stateName: 'MyState',
  onEnter: [{
    eventName: 'test-event',
    condition: iotevents.Expression.currentInput(input),
    actions: [
      new actions.SetVariableAction(
        'MyVariable',
        iotevents.Expression.inputAttribute(input, 'payload.temperature'),
      ),
    ],
  }],
});

Invoke a Lambda function

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

import * as iotevents from '@aws-cdk/aws-iotevents-alpha';
import * as actions from '@aws-cdk/aws-iotevents-actions-alpha';
import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const input: iotevents.IInput;
declare const func: lambda.IFunction;

const state = new iotevents.State({
  stateName: 'MyState',
  onEnter: [{
    eventName: 'test-event',
    condition: iotevents.Expression.currentInput(input),
    actions: [new actions.LambdaInvokeAction(func)],
  }],
});
2.141.0-alpha.0

3 days ago

2.140.0-alpha.0

9 days ago

2.139.1-alpha.0

12 days ago

2.139.0-alpha.0

17 days ago

2.138.0-alpha.0

23 days ago

2.137.0-alpha.0

1 month ago

2.136.1-alpha.0

1 month ago

2.136.0-alpha.0

1 month ago

2.135.0-alpha.0

1 month ago

2.134.0-alpha.0

2 months ago

2.133.0-alpha.0

2 months ago

2.132.1-alpha.0

2 months ago

2.132.0-alpha.0

2 months ago

2.131.0-alpha.0

2 months ago

2.129.0-alpha.0

3 months ago

2.130.0-alpha.0

3 months ago

2.128.0-alpha.0

3 months ago

2.127.0-alpha.0

3 months ago

2.126.0-alpha.0

3 months ago

2.125.0-alpha.0

3 months ago

2.124.0-alpha.0

4 months ago

2.123.0-alpha.0

4 months ago

2.122.0-alpha.0

4 months ago

2.121.0-alpha.0

4 months ago

2.120.0-alpha.0

4 months ago

2.121.1-alpha.0

4 months ago

2.119.0-alpha.0

4 months ago

2.118.0-alpha.0

4 months ago

2.117.0-alpha.0

5 months ago

2.116.1-alpha.0

5 months ago

2.116.0-alpha.0

5 months ago

2.115.0-alpha.0

5 months ago

2.114.1-alpha.0

5 months ago

2.114.0-alpha.0

5 months ago

2.113.0-alpha.0

5 months ago

2.111.0-alpha.0

6 months ago

2.112.0-alpha.0

5 months ago

2.109.0-alpha.0

6 months ago

2.106.0-alpha.0

6 months ago

2.110.0-alpha.0

6 months ago

2.105.0-alpha.0

6 months ago

2.110.1-alpha.0

6 months ago

2.108.1-alpha.0

6 months ago

2.107.0-alpha.0

6 months ago

2.108.0-alpha.0

6 months ago

2.106.1-alpha.0

6 months ago

2.103.0-alpha.0

7 months ago

2.103.1-alpha.0

7 months ago

2.102.1-alpha.0

7 months ago

2.104.0-alpha.0

6 months ago

2.100.0-alpha.0

7 months ago

2.88.0-alpha.0

10 months ago

2.101.1-alpha.0

7 months ago

2.99.1-alpha.0

7 months ago

2.90.0-alpha.0

9 months ago

2.96.1-alpha.0

8 months ago

2.98.0-alpha.0

8 months ago

2.89.0-alpha.0

10 months ago

2.95.0-alpha.0

8 months ago

2.96.0-alpha.0

8 months ago

2.94.0-alpha.0

8 months ago

2.95.1-alpha.0

8 months ago

2.97.0-alpha.0

8 months ago

2.102.0-alpha.0

7 months ago

2.87.0-alpha.0

10 months ago

2.91.0-alpha.0

9 months ago

2.92.0-alpha.0

9 months ago

2.86.0-alpha.0

11 months ago

2.99.0-alpha.0

8 months ago

2.97.1-alpha.0

8 months ago

2.96.2-alpha.0

8 months ago

2.101.0-alpha.0

7 months ago

2.93.0-alpha.0

9 months ago

2.83.0-alpha.0

11 months ago

2.82.0-alpha.0

11 months ago

2.84.0-alpha.0

11 months ago

2.85.0-alpha.0

11 months ago

2.83.1-alpha.0

11 months ago

2.78.0-alpha.0

1 year ago

2.75.0-alpha.0

1 year ago

2.80.0-alpha.0

12 months ago

2.74.0-alpha.0

1 year ago

2.79.1-alpha.0

1 year ago

2.81.0-alpha.0

12 months ago

2.79.0-alpha.0

1 year ago

2.76.0-alpha.0

1 year ago

2.77.0-alpha.0

1 year ago

2.75.1-alpha.0

1 year ago

2.73.0-alpha.0

1 year ago

2.65.0-alpha.0

1 year ago

2.71.0-alpha.0

1 year ago

2.63.1-alpha.0

1 year ago

2.72.0-alpha.0

1 year ago

2.68.0-alpha.0

1 year ago

2.64.0-alpha.0

1 year ago

2.66.1-alpha.0

1 year ago

2.63.2-alpha.0

1 year ago

2.67.0-alpha.0

1 year ago

2.72.1-alpha.0

1 year ago

2.69.0-alpha.0

1 year ago

2.70.0-alpha.0

1 year ago

2.66.0-alpha.0

1 year ago

2.59.0-alpha.0

1 year ago

2.62.0-alpha.0

1 year ago

2.58.1-alpha.0

1 year ago

2.61.0-alpha.0

1 year ago

2.62.1-alpha.0

1 year ago

2.60.0-alpha.0

1 year ago

2.57.0-alpha.0

1 year ago

2.63.0-alpha.0

1 year ago

2.58.0-alpha.0

1 year ago

2.61.1-alpha.0

1 year ago

2.62.2-alpha.0

1 year ago

2.46.0-alpha.0

2 years ago

2.52.0-alpha.0

1 year ago

2.53.0-alpha.0

1 year ago

2.56.0-alpha.0

1 year ago

2.49.0-alpha.0

2 years ago

2.51.1-alpha.0

1 year ago

2.52.1-alpha.0

1 year ago

2.49.1-alpha.0

2 years ago

2.55.1-alpha.0

1 year ago

2.48.0-alpha.0

2 years ago

2.50.0-alpha.0

2 years ago

2.54.0-alpha.0

1 year ago

2.56.1-alpha.0

1 year ago

2.55.0-alpha.0

1 year ago

2.47.0-alpha.0

2 years ago

2.51.0-alpha.0

1 year ago

2.45.0-alpha.0

2 years ago

2.44.0-alpha.0

2 years ago

2.38.1-alpha.0

2 years ago

2.41.0-alpha.0

2 years ago

2.42.1-alpha.0

2 years ago

2.38.0-alpha.0

2 years ago

2.40.0-alpha.0

2 years ago

2.39.0-alpha.0

2 years ago

2.39.1-alpha.0

2 years ago

2.43.1-alpha.0

2 years ago

2.42.0-alpha.0

2 years ago

2.43.0-alpha.0

2 years ago

2.33.0-alpha.0

2 years ago

2.31.2-alpha.0

2 years ago

2.31.1-alpha.0

2 years ago

2.35.0-alpha.0

2 years ago

2.31.0-alpha.0

2 years ago

2.27.0-alpha.0

2 years ago

2.29.1-alpha.0

2 years ago

2.29.0-alpha.0

2 years ago

2.32.1-alpha.0

2 years ago

2.26.0-alpha.0

2 years ago

2.32.0-alpha.0

2 years ago

2.37.0-alpha.0

2 years ago

2.37.1-alpha.0

2 years ago

2.30.0-alpha.0

2 years ago

2.34.1-alpha.0

2 years ago

2.36.0-alpha.0

2 years ago

2.34.2-alpha.0

2 years ago

2.28.0-alpha.0

2 years ago

2.34.0-alpha.0

2 years ago

2.28.1-alpha.0

2 years ago

2.25.0-alpha.0

2 years ago

2.24.1-alpha.0

2 years ago

2.24.0-alpha.0

2 years ago

2.23.0-alpha.0

2 years ago

2.22.0-alpha.0

2 years ago

2.16.0-alpha.0

2 years ago

2.19.0-alpha.0

2 years ago

2.18.0-alpha.0

2 years ago

2.21.1-alpha.0

2 years ago

2.17.0-alpha.0

2 years ago

2.21.0-alpha.0

2 years ago

2.20.0-alpha.0

2 years ago

2.14.0-alpha.0

2 years ago

2.15.0-alpha.0

2 years ago

2.13.0-alpha.0

2 years ago