Namespace Amazon.CDK.AWS.IoT
AWS IoT Construct Library
---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.
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 |
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 |
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. |
CfnDomainConfigurationProps | Properties for defining a |
CfnFleetMetric | A CloudFormation |
CfnFleetMetric.AggregationTypeProperty | The type of aggregation queries. |
CfnFleetMetricProps | Properties for defining a |
CfnJobTemplate | A CloudFormation |
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. |
CfnThingPrincipalAttachment | A CloudFormation |
CfnThingPrincipalAttachmentProps | Properties for defining a |
CfnThingProps | 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.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 |
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. |
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 |
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. |
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 |
ICfnAuthorizerProps | 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 |
ICfnThingPrincipalAttachmentProps | Properties for defining a |
ICfnThingProps | 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. |