Show / Hide Table of Contents

Namespace Amazon.CDK.AWS.IoT

AWS IoT Construct Library

--- cfn-resources: Stable
All classes with the <code>Cfn</code> prefix in this module (<a href="https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib">CFN Resources</a>) are always stable and safe to use.
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 <a href="https://semver.org/">Semantic Versioning</a> 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 Core lets you connect billions of IoT devices and route trillions of messages to AWS services without managing infrastructure.

Installation

Install the module:

$ npm i @aws-cdk/aws-iot

Import it into your code:

using Amazon.CDK.AWS.IoT;
using Amazon.CDK.AWS.IoT.Actions;

TopicRule

Create a topic rule that give your devices the ability to interact with AWS services. You can create a topic rule with an action that invoke the Lambda action as following:

Function func = new Function(this, "MyFunction", new FunctionProps {
    Runtime = Runtime.NODEJS_14_X,
    Handler = "index.handler",
    Code = Code.FromInline(@"
        exports.handler = (event) => {
          console.log(""It is test for lambda action of AWS IoT Rule."", event);
        };")
});

new TopicRule(this, "TopicRule", new TopicRuleProps {
    TopicRuleName = "MyTopicRule",  // optional
    Description = "invokes the lambda function",  // optional
    Sql = IotSql.FromStringAsVer20160323("SELECT topic(2) as device_id, timestamp() as timestamp FROM 'device/+/data'"),
    Actions = new [] { new LambdaFunctionAction(func) }
});

Or, you can add an action after constructing the TopicRule instance as following:

Function func;


TopicRule topicRule = new TopicRule(this, "TopicRule", new TopicRuleProps {
    Sql = IotSql.FromStringAsVer20160323("SELECT topic(2) as device_id, timestamp() as timestamp FROM 'device/+/data'")
});
topicRule.AddAction(new LambdaFunctionAction(func));

You can also supply errorAction as following, and the IoT Rule will trigger it if a rule's action is unable to perform:

using Amazon.CDK.AWS.Logs;


LogGroup logGroup = new LogGroup(this, "MyLogGroup");

new TopicRule(this, "TopicRule", new TopicRuleProps {
    Sql = IotSql.FromStringAsVer20160323("SELECT topic(2) as device_id, timestamp() as timestamp FROM 'device/+/data'"),
    ErrorAction = new CloudWatchLogsAction(logGroup)
});

If you wanna make the topic rule disable, add property enabled: false as following:

new TopicRule(this, "TopicRule", new TopicRuleProps {
    Sql = IotSql.FromStringAsVer20160323("SELECT topic(2) as device_id, timestamp() as timestamp FROM 'device/+/data'"),
    Enabled = false
});

See also @aws-cdk/aws-iot-actions for other actions.

Classes

ActionConfig

(experimental) Properties for an topic rule action.

CfnAccountAuditConfiguration

A CloudFormation AWS::IoT::AccountAuditConfiguration.

CfnAccountAuditConfiguration.AuditCheckConfigurationProperty

Which audit checks are enabled and disabled for this account.

CfnAccountAuditConfiguration.AuditCheckConfigurationsProperty

The types of audit checks that can be performed.

CfnAccountAuditConfiguration.AuditNotificationTargetConfigurationsProperty

The configuration of the audit notification target.

CfnAccountAuditConfiguration.AuditNotificationTargetProperty

Information about the targets to which audit notifications are sent.

CfnAccountAuditConfigurationProps

Properties for defining a CfnAccountAuditConfiguration.

CfnAuthorizer

A CloudFormation AWS::IoT::Authorizer.

CfnAuthorizerProps

Properties for defining a CfnAuthorizer.

CfnCertificate

A CloudFormation AWS::IoT::Certificate.

CfnCertificateProps

Properties for defining a CfnCertificate.

CfnCustomMetric

A CloudFormation AWS::IoT::CustomMetric.

CfnCustomMetricProps

Properties for defining a CfnCustomMetric.

CfnDimension

A CloudFormation AWS::IoT::Dimension.

CfnDimensionProps

Properties for defining a CfnDimension.

CfnDomainConfiguration

A CloudFormation AWS::IoT::DomainConfiguration.

CfnDomainConfiguration.AuthorizerConfigProperty

An object that specifies the authorization service for a domain.

CfnDomainConfiguration.ServerCertificateSummaryProperty

An object that contains information about a server certificate.

CfnDomainConfigurationProps

Properties for defining a CfnDomainConfiguration.

CfnFleetMetric

A CloudFormation AWS::IoT::FleetMetric.

CfnFleetMetric.AggregationTypeProperty

The type of aggregation queries.

CfnFleetMetricProps

Properties for defining a CfnFleetMetric.

CfnJobTemplate

A CloudFormation AWS::IoT::JobTemplate.

CfnJobTemplateProps

Properties for defining a CfnJobTemplate.

CfnLogging

A CloudFormation AWS::IoT::Logging.

CfnLoggingProps

Properties for defining a CfnLogging.

CfnMitigationAction

A CloudFormation AWS::IoT::MitigationAction.

CfnMitigationAction.ActionParamsProperty

Defines the type of action and the parameters for that action.

CfnMitigationAction.AddThingsToThingGroupParamsProperty

Parameters used when defining a mitigation action that move a set of things to a thing group.

CfnMitigationAction.EnableIoTLoggingParamsProperty

Parameters used when defining a mitigation action that enable AWS IoT Core logging.

CfnMitigationAction.PublishFindingToSnsParamsProperty

Parameters to define a mitigation action that publishes findings to Amazon SNS.

CfnMitigationAction.ReplaceDefaultPolicyVersionParamsProperty

Parameters to define a mitigation action that adds a blank policy to restrict permissions.

CfnMitigationAction.UpdateCACertificateParamsProperty

Parameters to define a mitigation action that changes the state of the CA certificate to inactive.

CfnMitigationAction.UpdateDeviceCertificateParamsProperty

Parameters to define a mitigation action that changes the state of the device certificate to inactive.

CfnMitigationActionProps

Properties for defining a CfnMitigationAction.

CfnPolicy

A CloudFormation AWS::IoT::Policy.

CfnPolicyPrincipalAttachment

A CloudFormation AWS::IoT::PolicyPrincipalAttachment.

CfnPolicyPrincipalAttachmentProps

Properties for defining a CfnPolicyPrincipalAttachment.

CfnPolicyProps

Properties for defining a CfnPolicy.

CfnProvisioningTemplate

A CloudFormation AWS::IoT::ProvisioningTemplate.

CfnProvisioningTemplate.ProvisioningHookProperty

Structure that contains payloadVersion and targetArn.

CfnProvisioningTemplateProps

Properties for defining a CfnProvisioningTemplate.

CfnResourceSpecificLogging

A CloudFormation AWS::IoT::ResourceSpecificLogging.

CfnResourceSpecificLoggingProps

Properties for defining a CfnResourceSpecificLogging.

CfnRoleAlias

A CloudFormation AWS::IoT::RoleAlias.

CfnRoleAliasProps

Properties for defining a CfnRoleAlias.

CfnScheduledAudit

A CloudFormation AWS::IoT::ScheduledAudit.

CfnScheduledAuditProps

Properties for defining a CfnScheduledAudit.

CfnSecurityProfile

A CloudFormation AWS::IoT::SecurityProfile.

CfnSecurityProfile.AlertTargetProperty

A structure containing the alert target ARN and the role ARN.

CfnSecurityProfile.BehaviorCriteriaProperty

The criteria by which the behavior is determined to be normal.

CfnSecurityProfile.BehaviorProperty

A Device Defender security profile behavior.

CfnSecurityProfile.MachineLearningDetectionConfigProperty

The MachineLearningDetectionConfig property type controls confidence of the machine learning model.

CfnSecurityProfile.MetricDimensionProperty

The dimension of the metric.

CfnSecurityProfile.MetricToRetainProperty

The metric you want to retain.

CfnSecurityProfile.MetricValueProperty

The value to be compared with the metric .

CfnSecurityProfile.StatisticalThresholdProperty

A statistical ranking (percentile) that indicates a threshold value by which a behavior is determined to be in compliance or in violation of the behavior.

CfnSecurityProfileProps

Properties for defining a CfnSecurityProfile.

CfnThing

A CloudFormation AWS::IoT::Thing.

CfnThing.AttributePayloadProperty

The AttributePayload property specifies up to three attributes for an AWS IoT as key-value pairs.

CfnThingPrincipalAttachment

A CloudFormation AWS::IoT::ThingPrincipalAttachment.

CfnThingPrincipalAttachmentProps

Properties for defining a CfnThingPrincipalAttachment.

CfnThingProps

Properties for defining a CfnThing.

CfnTopicRule

A CloudFormation AWS::IoT::TopicRule.

CfnTopicRule.ActionProperty

Describes the actions associated with a rule.

CfnTopicRule.AssetPropertyTimestampProperty

An asset property timestamp entry containing the following information.

CfnTopicRule.AssetPropertyValueProperty

An asset property value entry containing the following information.

CfnTopicRule.AssetPropertyVariantProperty

Contains an asset property value (of a single type).

CfnTopicRule.CloudwatchAlarmActionProperty

Describes an action that updates a CloudWatch alarm.

CfnTopicRule.CloudwatchLogsActionProperty

Describes an action that updates a CloudWatch log.

CfnTopicRule.CloudwatchMetricActionProperty

Describes an action that captures a CloudWatch metric.

CfnTopicRule.DynamoDBActionProperty

Describes an action to write to a DynamoDB table.

CfnTopicRule.DynamoDBv2ActionProperty

Describes an action to write to a DynamoDB table.

CfnTopicRule.ElasticsearchActionProperty

Describes an action that writes data to an Amazon OpenSearch Service domain.

CfnTopicRule.FirehoseActionProperty

Describes an action that writes data to an Amazon Kinesis Firehose stream.

CfnTopicRule.HttpActionHeaderProperty

The HTTP action header.

CfnTopicRule.HttpActionProperty

Send data to an HTTPS endpoint.

CfnTopicRule.HttpAuthorizationProperty

The authorization method used to send messages.

CfnTopicRule.IotAnalyticsActionProperty

Sends message data to an AWS IoT Analytics channel.

CfnTopicRule.IotEventsActionProperty

Sends an input to an AWS IoT Events detector.

CfnTopicRule.IotSiteWiseActionProperty

Describes an action to send data from an MQTT message that triggered the rule to AWS IoT SiteWise asset properties.

CfnTopicRule.KafkaActionProperty

Send messages to an Amazon Managed Streaming for Apache Kafka (Amazon MSK) or self-managed Apache Kafka cluster.

CfnTopicRule.KinesisActionProperty

Describes an action to write data to an Amazon Kinesis stream.

CfnTopicRule.LambdaActionProperty

Describes an action to invoke a Lambda function.

CfnTopicRule.OpenSearchActionProperty

Describes an action that writes data to an Amazon OpenSearch Service domain.

CfnTopicRule.PutAssetPropertyValueEntryProperty

An asset property value entry containing the following information.

CfnTopicRule.PutItemInputProperty

The input for the DynamoActionVS action that specifies the DynamoDB table to which the message data will be written.

CfnTopicRule.RepublishActionProperty

Describes an action to republish to another topic.

CfnTopicRule.S3ActionProperty

Describes an action to write data to an Amazon S3 bucket.

CfnTopicRule.SigV4AuthorizationProperty

For more information, see Signature Version 4 signing process .

CfnTopicRule.SnsActionProperty

Describes an action to publish to an Amazon SNS topic.

CfnTopicRule.SqsActionProperty

Describes an action to publish data to an Amazon SQS queue.

CfnTopicRule.StepFunctionsActionProperty

Starts execution of a Step Functions state machine.

CfnTopicRule.TimestreamActionProperty

Describes an action that writes records into an Amazon Timestream table.

CfnTopicRule.TimestreamDimensionProperty

Metadata attributes of the time series that are written in each measure record.

CfnTopicRule.TimestreamTimestampProperty

The value to use for the entry's timestamp.

CfnTopicRule.TopicRulePayloadProperty

Describes a rule.

CfnTopicRuleDestination

A CloudFormation AWS::IoT::TopicRuleDestination.

CfnTopicRuleDestination.HttpUrlDestinationSummaryProperty

HTTP URL destination properties.

CfnTopicRuleDestination.VpcDestinationPropertiesProperty

The properties of a virtual private cloud (VPC) destination.

CfnTopicRuleDestinationProps

Properties for defining a CfnTopicRuleDestination.

CfnTopicRuleProps

Properties for defining a CfnTopicRule.

IotSql

(experimental) Defines AWS IoT SQL.

IotSqlConfig

(experimental) The type returned from the bind() method in {@link IotSql}.

TopicRule

(experimental) Defines an AWS IoT Rule in this stack.

TopicRuleProps

(experimental) Properties for defining an AWS IoT Rule.

Interfaces

CfnAccountAuditConfiguration.IAuditCheckConfigurationProperty

Which audit checks are enabled and disabled for this account.

CfnAccountAuditConfiguration.IAuditCheckConfigurationsProperty

The types of audit checks that can be performed.

CfnAccountAuditConfiguration.IAuditNotificationTargetConfigurationsProperty

The configuration of the audit notification target.

CfnAccountAuditConfiguration.IAuditNotificationTargetProperty

Information about the targets to which audit notifications are sent.

CfnDomainConfiguration.IAuthorizerConfigProperty

An object that specifies the authorization service for a domain.

CfnDomainConfiguration.IServerCertificateSummaryProperty

An object that contains information about a server certificate.

CfnFleetMetric.IAggregationTypeProperty

The type of aggregation queries.

CfnMitigationAction.IActionParamsProperty

Defines the type of action and the parameters for that action.

CfnMitigationAction.IAddThingsToThingGroupParamsProperty

Parameters used when defining a mitigation action that move a set of things to a thing group.

CfnMitigationAction.IEnableIoTLoggingParamsProperty

Parameters used when defining a mitigation action that enable AWS IoT Core logging.

CfnMitigationAction.IPublishFindingToSnsParamsProperty

Parameters to define a mitigation action that publishes findings to Amazon SNS.

CfnMitigationAction.IReplaceDefaultPolicyVersionParamsProperty

Parameters to define a mitigation action that adds a blank policy to restrict permissions.

CfnMitigationAction.IUpdateCACertificateParamsProperty

Parameters to define a mitigation action that changes the state of the CA certificate to inactive.

CfnMitigationAction.IUpdateDeviceCertificateParamsProperty

Parameters to define a mitigation action that changes the state of the device certificate to inactive.

CfnProvisioningTemplate.IProvisioningHookProperty

Structure that contains payloadVersion and targetArn.

CfnSecurityProfile.IAlertTargetProperty

A structure containing the alert target ARN and the role ARN.

CfnSecurityProfile.IBehaviorCriteriaProperty

The criteria by which the behavior is determined to be normal.

CfnSecurityProfile.IBehaviorProperty

A Device Defender security profile behavior.

CfnSecurityProfile.IMachineLearningDetectionConfigProperty

The MachineLearningDetectionConfig property type controls confidence of the machine learning model.

CfnSecurityProfile.IMetricDimensionProperty

The dimension of the metric.

CfnSecurityProfile.IMetricToRetainProperty

The metric you want to retain.

CfnSecurityProfile.IMetricValueProperty

The value to be compared with the metric .

CfnSecurityProfile.IStatisticalThresholdProperty

A statistical ranking (percentile) that indicates a threshold value by which a behavior is determined to be in compliance or in violation of the behavior.

CfnThing.IAttributePayloadProperty

The AttributePayload property specifies up to three attributes for an AWS IoT as key-value pairs.

CfnTopicRule.IActionProperty

Describes the actions associated with a rule.

CfnTopicRule.IAssetPropertyTimestampProperty

An asset property timestamp entry containing the following information.

CfnTopicRule.IAssetPropertyValueProperty

An asset property value entry containing the following information.

CfnTopicRule.IAssetPropertyVariantProperty

Contains an asset property value (of a single type).

CfnTopicRule.ICloudwatchAlarmActionProperty

Describes an action that updates a CloudWatch alarm.

CfnTopicRule.ICloudwatchLogsActionProperty

Describes an action that updates a CloudWatch log.

CfnTopicRule.ICloudwatchMetricActionProperty

Describes an action that captures a CloudWatch metric.

CfnTopicRule.IDynamoDBActionProperty

Describes an action to write to a DynamoDB table.

CfnTopicRule.IDynamoDBv2ActionProperty

Describes an action to write to a DynamoDB table.

CfnTopicRule.IElasticsearchActionProperty

Describes an action that writes data to an Amazon OpenSearch Service domain.

CfnTopicRule.IFirehoseActionProperty

Describes an action that writes data to an Amazon Kinesis Firehose stream.

CfnTopicRule.IHttpActionHeaderProperty

The HTTP action header.

CfnTopicRule.IHttpActionProperty

Send data to an HTTPS endpoint.

CfnTopicRule.IHttpAuthorizationProperty

The authorization method used to send messages.

CfnTopicRule.IIotAnalyticsActionProperty

Sends message data to an AWS IoT Analytics channel.

CfnTopicRule.IIotEventsActionProperty

Sends an input to an AWS IoT Events detector.

CfnTopicRule.IIotSiteWiseActionProperty

Describes an action to send data from an MQTT message that triggered the rule to AWS IoT SiteWise asset properties.

CfnTopicRule.IKafkaActionProperty

Send messages to an Amazon Managed Streaming for Apache Kafka (Amazon MSK) or self-managed Apache Kafka cluster.

CfnTopicRule.IKinesisActionProperty

Describes an action to write data to an Amazon Kinesis stream.

CfnTopicRule.ILambdaActionProperty

Describes an action to invoke a Lambda function.

CfnTopicRule.IOpenSearchActionProperty

Describes an action that writes data to an Amazon OpenSearch Service domain.

CfnTopicRule.IPutAssetPropertyValueEntryProperty

An asset property value entry containing the following information.

CfnTopicRule.IPutItemInputProperty

The input for the DynamoActionVS action that specifies the DynamoDB table to which the message data will be written.

CfnTopicRule.IRepublishActionProperty

Describes an action to republish to another topic.

CfnTopicRule.IS3ActionProperty

Describes an action to write data to an Amazon S3 bucket.

CfnTopicRule.ISigV4AuthorizationProperty

For more information, see Signature Version 4 signing process .

CfnTopicRule.ISnsActionProperty

Describes an action to publish to an Amazon SNS topic.

CfnTopicRule.ISqsActionProperty

Describes an action to publish data to an Amazon SQS queue.

CfnTopicRule.IStepFunctionsActionProperty

Starts execution of a Step Functions state machine.

CfnTopicRule.ITimestreamActionProperty

Describes an action that writes records into an Amazon Timestream table.

CfnTopicRule.ITimestreamDimensionProperty

Metadata attributes of the time series that are written in each measure record.

CfnTopicRule.ITimestreamTimestampProperty

The value to use for the entry's timestamp.

CfnTopicRule.ITopicRulePayloadProperty

Describes a rule.

CfnTopicRuleDestination.IHttpUrlDestinationSummaryProperty

HTTP URL destination properties.

CfnTopicRuleDestination.IVpcDestinationPropertiesProperty

The properties of a virtual private cloud (VPC) destination.

IAction

(experimental) An abstract action for TopicRule.

IActionConfig

(experimental) Properties for an topic rule action.

ICfnAccountAuditConfigurationProps

Properties for defining a CfnAccountAuditConfiguration.

ICfnAuthorizerProps

Properties for defining a CfnAuthorizer.

ICfnCertificateProps

Properties for defining a CfnCertificate.

ICfnCustomMetricProps

Properties for defining a CfnCustomMetric.

ICfnDimensionProps

Properties for defining a CfnDimension.

ICfnDomainConfigurationProps

Properties for defining a CfnDomainConfiguration.

ICfnFleetMetricProps

Properties for defining a CfnFleetMetric.

ICfnJobTemplateProps

Properties for defining a CfnJobTemplate.

ICfnLoggingProps

Properties for defining a CfnLogging.

ICfnMitigationActionProps

Properties for defining a CfnMitigationAction.

ICfnPolicyPrincipalAttachmentProps

Properties for defining a CfnPolicyPrincipalAttachment.

ICfnPolicyProps

Properties for defining a CfnPolicy.

ICfnProvisioningTemplateProps

Properties for defining a CfnProvisioningTemplate.

ICfnResourceSpecificLoggingProps

Properties for defining a CfnResourceSpecificLogging.

ICfnRoleAliasProps

Properties for defining a CfnRoleAlias.

ICfnScheduledAuditProps

Properties for defining a CfnScheduledAudit.

ICfnSecurityProfileProps

Properties for defining a CfnSecurityProfile.

ICfnThingPrincipalAttachmentProps

Properties for defining a CfnThingPrincipalAttachment.

ICfnThingProps

Properties for defining a CfnThing.

ICfnTopicRuleDestinationProps

Properties for defining a CfnTopicRuleDestination.

ICfnTopicRuleProps

Properties for defining a CfnTopicRule.

IIotSqlConfig

(experimental) The type returned from the bind() method in {@link IotSql}.

ITopicRule

(experimental) Represents an AWS IoT Rule.

ITopicRuleProps

(experimental) Properties for defining an AWS IoT Rule.

Back to top Generated by DocFX