awscdkioteventsalpha

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

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

README

AWS::IoTEvents Construct Library


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.


AWS IoT Events enables you to monitor your equipment or device fleets for failures or changes in operation, and to trigger actions when such events occur.

Installation

Install the module:

$ npm i @aws-cdk/aws-iotevents

Import it into your code:

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

DetectorModel

The following example creates an AWS IoT Events detector model to your stack. The detector model need a reference to at least one AWS IoT Events input. AWS IoT Events inputs enable the detector to get MQTT payload values from IoT Core rules.

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

const input = new iotevents.Input(this, 'MyInput', {
  inputName: 'my_input', // optional
  attributeJsonPaths: ['payload.deviceId', 'payload.temperature'],
});

const warmState = new iotevents.State({
  stateName: 'warm',
  onEnter: [{
    eventName: 'test-event',
    condition: iotevents.Expression.currentInput(input),
  }],
});
const coldState = new iotevents.State({
  stateName: 'cold',
});

// transit to coldState when temperature is 10
warmState.transitionTo(coldState, {
  eventName: 'to_coldState', // optional property, default by combining the names of the States
  when: iotevents.Expression.eq(
    iotevents.Expression.inputAttribute(input, 'payload.temperature'),
    iotevents.Expression.fromString('10'),
  ),
});
// transit to warmState when temperature is 20
coldState.transitionTo(warmState, {
  when: iotevents.Expression.eq(
    iotevents.Expression.inputAttribute(input, 'payload.temperature'),
    iotevents.Expression.fromString('20'),
  ),
});

new iotevents.DetectorModel(this, 'MyDetectorModel', {
  detectorModelName: 'test-detector-model', // optional
  description: 'test-detector-model-description', // optional property, default is none
  evaluationMethod: iotevents.EventEvaluation.SERIAL, // optional property, default is iotevents.EventEvaluation.BATCH
  detectorKey: 'payload.deviceId', // optional property, default is none and single detector instance will be created and all inputs will be routed to it
  initialState: warmState,
});

To grant permissions to put messages in the input, you can use the grantWrite() method:

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

declare const grantable: iam.IGrantable;
const input = iotevents.Input.fromInputName(this, 'MyInput', 'my_input');

input.grantWrite(grantable);

Documentation

Overview

The CDK Construct Library for AWS::IoTEvents

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectorModel_IsConstruct

func DetectorModel_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead

func DetectorModel_IsResource

func DetectorModel_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource. Experimental.

func Input_IsConstruct

func Input_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead

func Input_IsResource

func Input_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource. Experimental.

func NewDetectorModel_Override

func NewDetectorModel_Override(d DetectorModel, scope constructs.Construct, id *string, props *DetectorModelProps)

Experimental.

func NewExpression_Override

func NewExpression_Override(e Expression)

Experimental.

func NewInput_Override

func NewInput_Override(i Input, scope constructs.Construct, id *string, props *InputProps)

Experimental.

func NewState_Override

func NewState_Override(s State, props *StateProps)

Experimental.

Types

type DetectorModel

type DetectorModel interface {
	awscdk.Resource
	IDetectorModel
	DetectorModelName() *string
	Env() *awscdk.ResourceEnvironment
	Node() constructs.Node
	PhysicalName() *string
	Stack() awscdk.Stack
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	GeneratePhysicalName() *string
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	GetResourceNameAttribute(nameAttr *string) *string
	ToString() *string
}

Defines an AWS IoT Events detector model in this stack.

TODO: EXAMPLE

Experimental.

func NewDetectorModel

func NewDetectorModel(scope constructs.Construct, id *string, props *DetectorModelProps) DetectorModel

Experimental.

type DetectorModelProps

type DetectorModelProps struct {
	// The state that is entered at the creation of each detector.
	// Experimental.
	InitialState State `json:"initialState" yaml:"initialState"`
	// A brief description of the detector model.
	// Experimental.
	Description *string `json:"description" yaml:"description"`
	// The value used to identify a detector instance.
	//
	// When a device or system sends input, a new
	// detector instance with a unique key value is created. AWS IoT Events can continue to route
	// input to its corresponding detector instance based on this identifying information.
	//
	// This parameter uses a JSON-path expression to select the attribute-value pair in the message
	// payload that is used for identification. To route the message to the correct detector instance,
	// the device must send a message payload that contains the same attribute-value.
	// Experimental.
	DetectorKey *string `json:"detectorKey" yaml:"detectorKey"`
	// The name of the detector model.
	// Experimental.
	DetectorModelName *string `json:"detectorModelName" yaml:"detectorModelName"`
	// Information about the order in which events are evaluated and how actions are executed.
	//
	// When setting to SERIAL, variables are updated and event conditions are evaluated in the order
	// that the events are defined.
	// When setting to BATCH, variables within a state are updated and events within a state are
	// performed only after all event conditions are evaluated.
	// Experimental.
	EvaluationMethod EventEvaluation `json:"evaluationMethod" yaml:"evaluationMethod"`
	// The role that grants permission to AWS IoT Events to perform its operations.
	// Experimental.
	Role awsiam.IRole `json:"role" yaml:"role"`
}

Properties for defining an AWS IoT Events detector model.

TODO: EXAMPLE

Experimental.

type Event

type Event struct {
	// The name of the event.
	// Experimental.
	EventName *string `json:"eventName" yaml:"eventName"`
	// The Boolean expression that, when TRUE, causes the actions to be performed.
	// Experimental.
	Condition Expression `json:"condition" yaml:"condition"`
}

Specifies the actions to be performed when the condition evaluates to TRUE.

TODO: EXAMPLE

Experimental.

type EventEvaluation

type EventEvaluation string

Information about the order in which events are evaluated and how actions are executed.

TODO: EXAMPLE

Experimental.

const (
	EventEvaluation_BATCH  EventEvaluation = "BATCH"
	EventEvaluation_SERIAL EventEvaluation = "SERIAL"
)

type Expression

type Expression interface {
	Evaluate() *string
}

Expression for events in Detector Model state.

TODO: EXAMPLE

See: https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-expressions.html

Experimental.

func Expression_And

func Expression_And(left Expression, right Expression) Expression

Create a expression for the AND operator. Experimental.

func Expression_CurrentInput

func Expression_CurrentInput(input IInput) Expression

Create a expression for function `currentInput()`.

It is evaluated to true if the specified input message was received. Experimental.

func Expression_Eq

func Expression_Eq(left Expression, right Expression) Expression

Create a expression for the Equal operator. Experimental.

func Expression_FromString

func Expression_FromString(value *string) Expression

Create a expression from the given string. Experimental.

func Expression_InputAttribute

func Expression_InputAttribute(input IInput, path *string) Expression

Create a expression for get an input attribute as `$input.TemperatureInput.temperatures[2]`. Experimental.

type IDetectorModel

type IDetectorModel interface {
	awscdk.IResource
	// The name of the detector model.
	// Experimental.
	DetectorModelName() *string
}

Represents an AWS IoT Events detector model. Experimental.

func DetectorModel_FromDetectorModelName

func DetectorModel_FromDetectorModelName(scope constructs.Construct, id *string, detectorModelName *string) IDetectorModel

Import an existing detector model. Experimental.

type IInput

type IInput interface {
	awscdk.IResource
	// Grant the indicated permissions on this input to the given IAM principal (Role/Group/User).
	// Experimental.
	Grant(grantee awsiam.IGrantable, actions ...*string) awsiam.Grant
	// Grant write permissions on this input and its contents to an IAM principal (Role/Group/User).
	// Experimental.
	GrantWrite(grantee awsiam.IGrantable) awsiam.Grant
	// The ARN of the input.
	// Experimental.
	InputArn() *string
	// The name of the input.
	// Experimental.
	InputName() *string
}

Represents an AWS IoT Events input. Experimental.

func Input_FromInputName

func Input_FromInputName(scope constructs.Construct, id *string, inputName *string) IInput

Import an existing input. Experimental.

type Input

type Input interface {
	awscdk.Resource
	IInput
	Env() *awscdk.ResourceEnvironment
	InputArn() *string
	InputName() *string
	Node() constructs.Node
	PhysicalName() *string
	Stack() awscdk.Stack
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	GeneratePhysicalName() *string
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	GetResourceNameAttribute(nameAttr *string) *string
	Grant(grantee awsiam.IGrantable, actions ...*string) awsiam.Grant
	GrantWrite(grantee awsiam.IGrantable) awsiam.Grant
	ToString() *string
}

Defines an AWS IoT Events input in this stack.

TODO: EXAMPLE

Experimental.

func NewInput

func NewInput(scope constructs.Construct, id *string, props *InputProps) Input

Experimental.

type InputProps

type InputProps struct {
	// An expression that specifies an attribute-value pair in a JSON structure.
	//
	// Use this to specify an attribute from the JSON payload that is made available
	// by the input. Inputs are derived from messages sent to AWS IoT Events (BatchPutMessage).
	// Each such message contains a JSON payload. The attribute (and its paired value)
	// specified here are available for use in the condition expressions used by detectors.
	// Experimental.
	AttributeJsonPaths *[]*string `json:"attributeJsonPaths" yaml:"attributeJsonPaths"`
	// The name of the input.
	// Experimental.
	InputName *string `json:"inputName" yaml:"inputName"`
}

Properties for defining an AWS IoT Events input.

TODO: EXAMPLE

Experimental.

type State

type State interface {
	StateName() *string
	TransitionTo(targetState State, options *TransitionOptions)
}

Defines a state of a detector.

TODO: EXAMPLE

Experimental.

func NewState

func NewState(props *StateProps) State

Experimental.

type StateProps

type StateProps struct {
	// The name of the state.
	// Experimental.
	StateName *string `json:"stateName" yaml:"stateName"`
	// Specifies the events on enter.
	//
	// the conditions of the events are evaluated when the state is entered.
	// If the condition is `TRUE`, the actions of the event are performed.
	// Experimental.
	OnEnter *[]*Event `json:"onEnter" yaml:"onEnter"`
}

Properties for defining a state of a detector.

TODO: EXAMPLE

Experimental.

type TransitionOptions

type TransitionOptions struct {
	// The condition that is used to determine to cause the state transition and the actions.
	//
	// When this was evaluated to TRUE, the state transition and the actions are triggered.
	// Experimental.
	When Expression `json:"when" yaml:"when"`
	// The name of the event.
	// Experimental.
	EventName *string `json:"eventName" yaml:"eventName"`
}

Properties for options of state transition.

TODO: EXAMPLE

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