Namespace Amazon.CDK.AWS.IoT
AWS IoT Construct Library
---AWS CDK v1 has reached End-of-Support on 2023-06-01.
This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see the Migrating to AWS CDK v2 guide.
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:
var 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;
var 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;
var 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 |
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 |
CfnAuthorizer | A CloudFormation |
CfnAuthorizerProps | Properties for defining a |
CfnBillingGroup | A CloudFormation |
CfnBillingGroup.BillingGroupPropertiesProperty | The properties of a billing group. |
CfnBillingGroupProps | Properties for defining a |
CfnCACertificate | A CloudFormation |
CfnCACertificate.RegistrationConfigProperty | The registration configuration. |
CfnCACertificateProps | Properties for defining a |
CfnCertificate | A CloudFormation |
CfnCertificateProps | Properties for defining a |
CfnCustomMetric | A CloudFormation |
CfnCustomMetricProps | Properties for defining a |
CfnDimension | A CloudFormation |
CfnDimensionProps | Properties for defining a |
CfnDomainConfiguration | A CloudFormation |
CfnDomainConfiguration.AuthorizerConfigProperty | An object that specifies the authorization service for a domain. |
CfnDomainConfiguration.ServerCertificateSummaryProperty | An object that contains information about a server certificate. |
CfnDomainConfiguration.TlsConfigProperty | |
CfnDomainConfigurationProps | Properties for defining a |
CfnFleetMetric | A CloudFormation |
CfnFleetMetric.AggregationTypeProperty | The type of aggregation queries. |
CfnFleetMetricProps | Properties for defining a |
CfnJobTemplate | A CloudFormation |
CfnJobTemplate.AbortConfigProperty | The criteria that determine when and how a job abort takes place. |
CfnJobTemplate.AbortCriteriaProperty | The criteria that determine when and how a job abort takes place. |
CfnJobTemplate.ExponentialRolloutRateProperty | Allows you to create an exponential rate of rollout for a job. |
CfnJobTemplate.JobExecutionsRetryConfigProperty | The configuration that determines how many retries are allowed for each failure type for a job. |
CfnJobTemplate.JobExecutionsRolloutConfigProperty | Allows you to create a staged rollout of a job. |
CfnJobTemplate.MaintenanceWindowProperty | An optional configuration within the |
CfnJobTemplate.PresignedUrlConfigProperty | Configuration for pre-signed S3 URLs. |
CfnJobTemplate.RateIncreaseCriteriaProperty | Allows you to define a criteria to initiate the increase in rate of rollout for a job. |
CfnJobTemplate.RetryCriteriaProperty | The criteria that determines how many retries are allowed for each failure type for a job. |
CfnJobTemplate.TimeoutConfigProperty | Specifies the amount of time each device has to finish its execution of the job. |
CfnJobTemplateProps | Properties for defining a |
CfnLogging | A CloudFormation |
CfnLoggingProps | Properties for defining a |
CfnMitigationAction | A CloudFormation |
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 |
CfnPolicy | A CloudFormation |
CfnPolicyPrincipalAttachment | A CloudFormation |
CfnPolicyPrincipalAttachmentProps | Properties for defining a |
CfnPolicyProps | Properties for defining a |
CfnProvisioningTemplate | A CloudFormation |
CfnProvisioningTemplate.ProvisioningHookProperty | Structure that contains payloadVersion and targetArn. |
CfnProvisioningTemplateProps | Properties for defining a |
CfnResourceSpecificLogging | A CloudFormation |
CfnResourceSpecificLoggingProps | Properties for defining a |
CfnRoleAlias | A CloudFormation |
CfnRoleAliasProps | Properties for defining a |
CfnScheduledAudit | A CloudFormation |
CfnScheduledAuditProps | Properties for defining a |
CfnSecurityProfile | A CloudFormation |
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 |
CfnSecurityProfile.MetricDimensionProperty | The dimension of the metric. |
CfnSecurityProfile.MetricToRetainProperty | The metric you want to retain. |
CfnSecurityProfile.MetricValueProperty | The value to be compared with the |
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 |
CfnThing | A CloudFormation |
CfnThing.AttributePayloadProperty | The AttributePayload property specifies up to three attributes for an AWS IoT as key-value pairs. |
CfnThingGroup | A CloudFormation |
CfnThingGroup.AttributePayloadProperty | The attribute payload. |
CfnThingGroup.ThingGroupPropertiesProperty | Thing group properties. |
CfnThingGroupProps | Properties for defining a |
CfnThingPrincipalAttachment | A CloudFormation |
CfnThingPrincipalAttachmentProps | Properties for defining a |
CfnThingProps | Properties for defining a |
CfnThingType | A CloudFormation |
CfnThingType.ThingTypePropertiesProperty | The ThingTypeProperties contains information about the thing type including: a thing type description, and a list of searchable thing attribute names. |
CfnThingTypeProps | Properties for defining a |
CfnTopicRule | A CloudFormation |
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.LocationActionProperty | Describes an action to send device location updates from an MQTT message to an Amazon Location tracker resource. |
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.RepublishActionHeadersProperty | Specifies MQTT Version 5.0 headers information. For more information, see MQTT in the IoT Core Developer Guide. |
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.TimestampProperty | Describes how to interpret an application-defined timestamp value from an MQTT message payload and the precision of that value. |
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. |
CfnTopicRule.UserPropertyProperty | A key-value pair that you define in the header. |
CfnTopicRuleDestination | A CloudFormation |
CfnTopicRuleDestination.HttpUrlDestinationSummaryProperty | HTTP URL destination properties. |
CfnTopicRuleDestination.VpcDestinationPropertiesProperty | The properties of a virtual private cloud (VPC) destination. |
CfnTopicRuleDestinationProps | Properties for defining a |
CfnTopicRuleProps | Properties for defining a |
IotSql | (experimental) Defines AWS IoT SQL. |
IotSqlConfig | (experimental) The type returned from the |
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. |
CfnBillingGroup.IBillingGroupPropertiesProperty | The properties of a billing group. |
CfnCACertificate.IRegistrationConfigProperty | The registration configuration. |
CfnDomainConfiguration.IAuthorizerConfigProperty | An object that specifies the authorization service for a domain. |
CfnDomainConfiguration.IServerCertificateSummaryProperty | An object that contains information about a server certificate. |
CfnDomainConfiguration.ITlsConfigProperty | |
CfnFleetMetric.IAggregationTypeProperty | The type of aggregation queries. |
CfnJobTemplate.IAbortConfigProperty | The criteria that determine when and how a job abort takes place. |
CfnJobTemplate.IAbortCriteriaProperty | The criteria that determine when and how a job abort takes place. |
CfnJobTemplate.IExponentialRolloutRateProperty | Allows you to create an exponential rate of rollout for a job. |
CfnJobTemplate.IJobExecutionsRetryConfigProperty | The configuration that determines how many retries are allowed for each failure type for a job. |
CfnJobTemplate.IJobExecutionsRolloutConfigProperty | Allows you to create a staged rollout of a job. |
CfnJobTemplate.IMaintenanceWindowProperty | An optional configuration within the |
CfnJobTemplate.IPresignedUrlConfigProperty | Configuration for pre-signed S3 URLs. |
CfnJobTemplate.IRateIncreaseCriteriaProperty | Allows you to define a criteria to initiate the increase in rate of rollout for a job. |
CfnJobTemplate.IRetryCriteriaProperty | The criteria that determines how many retries are allowed for each failure type for a job. |
CfnJobTemplate.ITimeoutConfigProperty | Specifies the amount of time each device has to finish its execution of the job. |
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 |
CfnSecurityProfile.IMetricDimensionProperty | The dimension of the metric. |
CfnSecurityProfile.IMetricToRetainProperty | The metric you want to retain. |
CfnSecurityProfile.IMetricValueProperty | The value to be compared with the |
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. |
CfnThingGroup.IAttributePayloadProperty | The attribute payload. |
CfnThingGroup.IThingGroupPropertiesProperty | Thing group properties. |
CfnThingType.IThingTypePropertiesProperty | The ThingTypeProperties contains information about the thing type including: a thing type description, and a list of searchable thing attribute names. |
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.ILocationActionProperty | Describes an action to send device location updates from an MQTT message to an Amazon Location tracker resource. |
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.IRepublishActionHeadersProperty | Specifies MQTT Version 5.0 headers information. For more information, see MQTT in the IoT Core Developer Guide. |
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.ITimestampProperty | Describes how to interpret an application-defined timestamp value from an MQTT message payload and the precision of that value. |
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. |
CfnTopicRule.IUserPropertyProperty | A key-value pair that you define in the header. |
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 |
ICfnAuthorizerProps | Properties for defining a |
ICfnBillingGroupProps | Properties for defining a |
ICfnCACertificateProps | Properties for defining a |
ICfnCertificateProps | Properties for defining a |
ICfnCustomMetricProps | Properties for defining a |
ICfnDimensionProps | Properties for defining a |
ICfnDomainConfigurationProps | Properties for defining a |
ICfnFleetMetricProps | Properties for defining a |
ICfnJobTemplateProps | Properties for defining a |
ICfnLoggingProps | Properties for defining a |
ICfnMitigationActionProps | Properties for defining a |
ICfnPolicyPrincipalAttachmentProps | Properties for defining a |
ICfnPolicyProps | Properties for defining a |
ICfnProvisioningTemplateProps | Properties for defining a |
ICfnResourceSpecificLoggingProps | Properties for defining a |
ICfnRoleAliasProps | Properties for defining a |
ICfnScheduledAuditProps | Properties for defining a |
ICfnSecurityProfileProps | Properties for defining a |
ICfnThingGroupProps | Properties for defining a |
ICfnThingPrincipalAttachmentProps | Properties for defining a |
ICfnThingProps | Properties for defining a |
ICfnThingTypeProps | Properties for defining a |
ICfnTopicRuleDestinationProps | Properties for defining a |
ICfnTopicRuleProps | Properties for defining a |
IIotSqlConfig | (experimental) The type returned from the |
ITopicRule | (experimental) Represents an AWS IoT Rule. |
ITopicRuleProps | (experimental) Properties for defining an AWS IoT Rule. |