Package software.amazon.awscdk.services.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:
import software.amazon.awscdk.services.iot.*; import software.amazon.awscdk.services.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 = Function.Builder.create(this, "MyFunction")
.runtime(Runtime.NODEJS_14_X)
.handler("index.handler")
.code(Code.fromInline("\n exports.handler = (event) => {\n console.log(\"It is test for lambda action of AWS IoT Rule.\", event);\n };"))
.build();
TopicRule.Builder.create(this, "TopicRule")
.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(List.of(new LambdaFunctionAction(func)))
.build();
Or, you can add an action after constructing the TopicRule instance as following:
Function func;
TopicRule topicRule = TopicRule.Builder.create(this, "TopicRule")
.sql(IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id, timestamp() as timestamp FROM 'device/+/data'"))
.build();
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:
import software.amazon.awscdk.services.logs.*;
LogGroup logGroup = new LogGroup(this, "MyLogGroup");
TopicRule.Builder.create(this, "TopicRule")
.sql(IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id, timestamp() as timestamp FROM 'device/+/data'"))
.errorAction(new CloudWatchLogsAction(logGroup))
.build();
If you wanna make the topic rule disable, add property enabled: false as following:
TopicRule.Builder.create(this, "TopicRule")
.sql(IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id, timestamp() as timestamp FROM 'device/+/data'"))
.enabled(false)
.build();
See also @aws-cdk/aws-iot-actions for other actions. Deprecated: 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 https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html
-
ClassDescription(experimental) Properties for an topic rule action.A builder for
ActionConfigAn implementation forActionConfigA CloudFormationAWS::IoT::AccountAuditConfiguration.Which audit checks are enabled and disabled for this account.An implementation forCfnAccountAuditConfiguration.AuditCheckConfigurationPropertyThe types of audit checks that can be performed.An implementation forCfnAccountAuditConfiguration.AuditCheckConfigurationsPropertyThe configuration of the audit notification target.An implementation forCfnAccountAuditConfiguration.AuditNotificationTargetConfigurationsPropertyInformation about the targets to which audit notifications are sent.An implementation forCfnAccountAuditConfiguration.AuditNotificationTargetPropertyA fluent builder forCfnAccountAuditConfiguration.Properties for defining aCfnAccountAuditConfiguration.A builder forCfnAccountAuditConfigurationPropsAn implementation forCfnAccountAuditConfigurationPropsA CloudFormationAWS::IoT::Authorizer.A fluent builder forCfnAuthorizer.Properties for defining aCfnAuthorizer.A builder forCfnAuthorizerPropsAn implementation forCfnAuthorizerPropsA CloudFormationAWS::IoT::BillingGroup.The properties of a billing group.A builder forCfnBillingGroup.BillingGroupPropertiesPropertyAn implementation forCfnBillingGroup.BillingGroupPropertiesPropertyA fluent builder forCfnBillingGroup.Properties for defining aCfnBillingGroup.A builder forCfnBillingGroupPropsAn implementation forCfnBillingGroupPropsA CloudFormationAWS::IoT::CACertificate.A fluent builder forCfnCACertificate.The registration configuration.A builder forCfnCACertificate.RegistrationConfigPropertyAn implementation forCfnCACertificate.RegistrationConfigPropertyProperties for defining aCfnCACertificate.A builder forCfnCACertificatePropsAn implementation forCfnCACertificatePropsA CloudFormationAWS::IoT::Certificate.A fluent builder forCfnCertificate.Properties for defining aCfnCertificate.A builder forCfnCertificatePropsAn implementation forCfnCertificatePropsA CloudFormationAWS::IoT::CustomMetric.A fluent builder forCfnCustomMetric.Properties for defining aCfnCustomMetric.A builder forCfnCustomMetricPropsAn implementation forCfnCustomMetricPropsA CloudFormationAWS::IoT::Dimension.A fluent builder forCfnDimension.Properties for defining aCfnDimension.A builder forCfnDimensionPropsAn implementation forCfnDimensionPropsA CloudFormationAWS::IoT::DomainConfiguration.An object that specifies the authorization service for a domain.A builder forCfnDomainConfiguration.AuthorizerConfigPropertyAn implementation forCfnDomainConfiguration.AuthorizerConfigPropertyA fluent builder forCfnDomainConfiguration.An object that contains information about a server certificate.A builder forCfnDomainConfiguration.ServerCertificateSummaryPropertyAn implementation forCfnDomainConfiguration.ServerCertificateSummaryPropertyExample:A builder forCfnDomainConfiguration.TlsConfigPropertyAn implementation forCfnDomainConfiguration.TlsConfigPropertyProperties for defining aCfnDomainConfiguration.A builder forCfnDomainConfigurationPropsAn implementation forCfnDomainConfigurationPropsA CloudFormationAWS::IoT::FleetMetric.The type of aggregation queries.A builder forCfnFleetMetric.AggregationTypePropertyAn implementation forCfnFleetMetric.AggregationTypePropertyA fluent builder forCfnFleetMetric.Properties for defining aCfnFleetMetric.A builder forCfnFleetMetricPropsAn implementation forCfnFleetMetricPropsA CloudFormationAWS::IoT::JobTemplate.The criteria that determine when and how a job abort takes place.A builder forCfnJobTemplate.AbortConfigPropertyAn implementation forCfnJobTemplate.AbortConfigPropertyThe criteria that determine when and how a job abort takes place.A builder forCfnJobTemplate.AbortCriteriaPropertyAn implementation forCfnJobTemplate.AbortCriteriaPropertyA fluent builder forCfnJobTemplate.Allows you to create an exponential rate of rollout for a job.A builder forCfnJobTemplate.ExponentialRolloutRatePropertyAn implementation forCfnJobTemplate.ExponentialRolloutRatePropertyThe configuration that determines how many retries are allowed for each failure type for a job.A builder forCfnJobTemplate.JobExecutionsRetryConfigPropertyAn implementation forCfnJobTemplate.JobExecutionsRetryConfigPropertyAllows you to create a staged rollout of a job.A builder forCfnJobTemplate.JobExecutionsRolloutConfigPropertyAn implementation forCfnJobTemplate.JobExecutionsRolloutConfigPropertyAn optional configuration within theSchedulingConfigto setup a recurring maintenance window with a predetermined start time and duration for the rollout of a job document to all devices in a target group for a job.A builder forCfnJobTemplate.MaintenanceWindowPropertyAn implementation forCfnJobTemplate.MaintenanceWindowPropertyConfiguration for pre-signed S3 URLs.A builder forCfnJobTemplate.PresignedUrlConfigPropertyAn implementation forCfnJobTemplate.PresignedUrlConfigPropertyAllows you to define a criteria to initiate the increase in rate of rollout for a job.A builder forCfnJobTemplate.RateIncreaseCriteriaPropertyAn implementation forCfnJobTemplate.RateIncreaseCriteriaPropertyThe criteria that determines how many retries are allowed for each failure type for a job.A builder forCfnJobTemplate.RetryCriteriaPropertyAn implementation forCfnJobTemplate.RetryCriteriaPropertySpecifies the amount of time each device has to finish its execution of the job.A builder forCfnJobTemplate.TimeoutConfigPropertyAn implementation forCfnJobTemplate.TimeoutConfigPropertyProperties for defining aCfnJobTemplate.A builder forCfnJobTemplatePropsAn implementation forCfnJobTemplatePropsA CloudFormationAWS::IoT::Logging.A fluent builder forCfnLogging.Properties for defining aCfnLogging.A builder forCfnLoggingPropsAn implementation forCfnLoggingPropsA CloudFormationAWS::IoT::MitigationAction.Defines the type of action and the parameters for that action.A builder forCfnMitigationAction.ActionParamsPropertyAn implementation forCfnMitigationAction.ActionParamsPropertyParameters used when defining a mitigation action that move a set of things to a thing group.A builder forCfnMitigationAction.AddThingsToThingGroupParamsPropertyAn implementation forCfnMitigationAction.AddThingsToThingGroupParamsPropertyA fluent builder forCfnMitigationAction.Parameters used when defining a mitigation action that enable AWS IoT Core logging.A builder forCfnMitigationAction.EnableIoTLoggingParamsPropertyAn implementation forCfnMitigationAction.EnableIoTLoggingParamsPropertyParameters to define a mitigation action that publishes findings to Amazon SNS.A builder forCfnMitigationAction.PublishFindingToSnsParamsPropertyAn implementation forCfnMitigationAction.PublishFindingToSnsParamsPropertyParameters to define a mitigation action that adds a blank policy to restrict permissions.An implementation forCfnMitigationAction.ReplaceDefaultPolicyVersionParamsPropertyParameters to define a mitigation action that changes the state of the CA certificate to inactive.A builder forCfnMitigationAction.UpdateCACertificateParamsPropertyAn implementation forCfnMitigationAction.UpdateCACertificateParamsPropertyParameters to define a mitigation action that changes the state of the device certificate to inactive.An implementation forCfnMitigationAction.UpdateDeviceCertificateParamsPropertyProperties for defining aCfnMitigationAction.A builder forCfnMitigationActionPropsAn implementation forCfnMitigationActionPropsA CloudFormationAWS::IoT::Policy.A fluent builder forCfnPolicy.A CloudFormationAWS::IoT::PolicyPrincipalAttachment.A fluent builder forCfnPolicyPrincipalAttachment.Properties for defining aCfnPolicyPrincipalAttachment.A builder forCfnPolicyPrincipalAttachmentPropsAn implementation forCfnPolicyPrincipalAttachmentPropsProperties for defining aCfnPolicy.A builder forCfnPolicyPropsAn implementation forCfnPolicyPropsA CloudFormationAWS::IoT::ProvisioningTemplate.A fluent builder forCfnProvisioningTemplate.Structure that contains payloadVersion and targetArn.A builder forCfnProvisioningTemplate.ProvisioningHookPropertyAn implementation forCfnProvisioningTemplate.ProvisioningHookPropertyProperties for defining aCfnProvisioningTemplate.A builder forCfnProvisioningTemplatePropsAn implementation forCfnProvisioningTemplatePropsA CloudFormationAWS::IoT::ResourceSpecificLogging.A fluent builder forCfnResourceSpecificLogging.Properties for defining aCfnResourceSpecificLogging.A builder forCfnResourceSpecificLoggingPropsAn implementation forCfnResourceSpecificLoggingPropsA CloudFormationAWS::IoT::RoleAlias.A fluent builder forCfnRoleAlias.Properties for defining aCfnRoleAlias.A builder forCfnRoleAliasPropsAn implementation forCfnRoleAliasPropsA CloudFormationAWS::IoT::ScheduledAudit.A fluent builder forCfnScheduledAudit.Properties for defining aCfnScheduledAudit.A builder forCfnScheduledAuditPropsAn implementation forCfnScheduledAuditPropsA CloudFormationAWS::IoT::SecurityProfile.A structure containing the alert target ARN and the role ARN.A builder forCfnSecurityProfile.AlertTargetPropertyAn implementation forCfnSecurityProfile.AlertTargetPropertyThe criteria by which the behavior is determined to be normal.A builder forCfnSecurityProfile.BehaviorCriteriaPropertyAn implementation forCfnSecurityProfile.BehaviorCriteriaPropertyA Device Defender security profile behavior.A builder forCfnSecurityProfile.BehaviorPropertyAn implementation forCfnSecurityProfile.BehaviorPropertyA fluent builder forCfnSecurityProfile.TheMachineLearningDetectionConfigproperty type controls confidence of the machine learning model.An implementation forCfnSecurityProfile.MachineLearningDetectionConfigPropertyThe dimension of the metric.A builder forCfnSecurityProfile.MetricDimensionPropertyAn implementation forCfnSecurityProfile.MetricDimensionPropertyThe metric you want to retain.A builder forCfnSecurityProfile.MetricToRetainPropertyAn implementation forCfnSecurityProfile.MetricToRetainPropertyThe value to be compared with themetric.A builder forCfnSecurityProfile.MetricValuePropertyAn implementation forCfnSecurityProfile.MetricValuePropertyA statistical ranking (percentile) that indicates a threshold value by which a behavior is determined to be in compliance or in violation of the behavior.A builder forCfnSecurityProfile.StatisticalThresholdPropertyAn implementation forCfnSecurityProfile.StatisticalThresholdPropertyProperties for defining aCfnSecurityProfile.A builder forCfnSecurityProfilePropsAn implementation forCfnSecurityProfilePropsA CloudFormationAWS::IoT::Thing.The AttributePayload property specifies up to three attributes for an AWS IoT as key-value pairs.A builder forCfnThing.AttributePayloadPropertyAn implementation forCfnThing.AttributePayloadPropertyA fluent builder forCfnThing.A CloudFormationAWS::IoT::ThingGroup.The attribute payload.A builder forCfnThingGroup.AttributePayloadPropertyAn implementation forCfnThingGroup.AttributePayloadPropertyA fluent builder forCfnThingGroup.Thing group properties.A builder forCfnThingGroup.ThingGroupPropertiesPropertyAn implementation forCfnThingGroup.ThingGroupPropertiesPropertyProperties for defining aCfnThingGroup.A builder forCfnThingGroupPropsAn implementation forCfnThingGroupPropsA CloudFormationAWS::IoT::ThingPrincipalAttachment.A fluent builder forCfnThingPrincipalAttachment.Properties for defining aCfnThingPrincipalAttachment.A builder forCfnThingPrincipalAttachmentPropsAn implementation forCfnThingPrincipalAttachmentPropsProperties for defining aCfnThing.A builder forCfnThingPropsAn implementation forCfnThingPropsA CloudFormationAWS::IoT::ThingType.A fluent builder forCfnThingType.The ThingTypeProperties contains information about the thing type including: a thing type description, and a list of searchable thing attribute names.A builder forCfnThingType.ThingTypePropertiesPropertyAn implementation forCfnThingType.ThingTypePropertiesPropertyProperties for defining aCfnThingType.A builder forCfnThingTypePropsAn implementation forCfnThingTypePropsA CloudFormationAWS::IoT::TopicRule.Describes the actions associated with a rule.A builder forCfnTopicRule.ActionPropertyAn implementation forCfnTopicRule.ActionPropertyAn asset property timestamp entry containing the following information.A builder forCfnTopicRule.AssetPropertyTimestampPropertyAn implementation forCfnTopicRule.AssetPropertyTimestampPropertyAn asset property value entry containing the following information.A builder forCfnTopicRule.AssetPropertyValuePropertyAn implementation forCfnTopicRule.AssetPropertyValuePropertyContains an asset property value (of a single type).A builder forCfnTopicRule.AssetPropertyVariantPropertyAn implementation forCfnTopicRule.AssetPropertyVariantPropertyA fluent builder forCfnTopicRule.Describes an action that updates a CloudWatch alarm.A builder forCfnTopicRule.CloudwatchAlarmActionPropertyAn implementation forCfnTopicRule.CloudwatchAlarmActionPropertyDescribes an action that updates a CloudWatch log.A builder forCfnTopicRule.CloudwatchLogsActionPropertyAn implementation forCfnTopicRule.CloudwatchLogsActionPropertyDescribes an action that captures a CloudWatch metric.A builder forCfnTopicRule.CloudwatchMetricActionPropertyAn implementation forCfnTopicRule.CloudwatchMetricActionPropertyDescribes an action to write to a DynamoDB table.A builder forCfnTopicRule.DynamoDBActionPropertyAn implementation forCfnTopicRule.DynamoDBActionPropertyDescribes an action to write to a DynamoDB table.A builder forCfnTopicRule.DynamoDBv2ActionPropertyAn implementation forCfnTopicRule.DynamoDBv2ActionPropertyDescribes an action that writes data to an Amazon OpenSearch Service domain.A builder forCfnTopicRule.ElasticsearchActionPropertyAn implementation forCfnTopicRule.ElasticsearchActionPropertyDescribes an action that writes data to an Amazon Kinesis Firehose stream.A builder forCfnTopicRule.FirehoseActionPropertyAn implementation forCfnTopicRule.FirehoseActionPropertyThe HTTP action header.A builder forCfnTopicRule.HttpActionHeaderPropertyAn implementation forCfnTopicRule.HttpActionHeaderPropertySend data to an HTTPS endpoint.A builder forCfnTopicRule.HttpActionPropertyAn implementation forCfnTopicRule.HttpActionPropertyThe authorization method used to send messages.A builder forCfnTopicRule.HttpAuthorizationPropertyAn implementation forCfnTopicRule.HttpAuthorizationPropertySends message data to an AWS IoT Analytics channel.A builder forCfnTopicRule.IotAnalyticsActionPropertyAn implementation forCfnTopicRule.IotAnalyticsActionPropertySends an input to an AWS IoT Events detector.A builder forCfnTopicRule.IotEventsActionPropertyAn implementation forCfnTopicRule.IotEventsActionPropertyDescribes an action to send data from an MQTT message that triggered the rule to AWS IoT SiteWise asset properties.A builder forCfnTopicRule.IotSiteWiseActionPropertyAn implementation forCfnTopicRule.IotSiteWiseActionPropertySend messages to an Amazon Managed Streaming for Apache Kafka (Amazon MSK) or self-managed Apache Kafka cluster.A builder forCfnTopicRule.KafkaActionPropertyAn implementation forCfnTopicRule.KafkaActionPropertyDescribes an action to write data to an Amazon Kinesis stream.A builder forCfnTopicRule.KinesisActionPropertyAn implementation forCfnTopicRule.KinesisActionPropertyDescribes an action to invoke a Lambda function.A builder forCfnTopicRule.LambdaActionPropertyAn implementation forCfnTopicRule.LambdaActionPropertyDescribes an action to send device location updates from an MQTT message to an Amazon Location tracker resource.A builder forCfnTopicRule.LocationActionPropertyAn implementation forCfnTopicRule.LocationActionPropertyDescribes an action that writes data to an Amazon OpenSearch Service domain.A builder forCfnTopicRule.OpenSearchActionPropertyAn implementation forCfnTopicRule.OpenSearchActionPropertyAn asset property value entry containing the following information.A builder forCfnTopicRule.PutAssetPropertyValueEntryPropertyAn implementation forCfnTopicRule.PutAssetPropertyValueEntryPropertyThe input for the DynamoActionVS action that specifies the DynamoDB table to which the message data will be written.A builder forCfnTopicRule.PutItemInputPropertyAn implementation forCfnTopicRule.PutItemInputPropertySpecifies MQTT Version 5.0 headers information.A builder forCfnTopicRule.RepublishActionHeadersPropertyAn implementation forCfnTopicRule.RepublishActionHeadersPropertyDescribes an action to republish to another topic.A builder forCfnTopicRule.RepublishActionPropertyAn implementation forCfnTopicRule.RepublishActionPropertyDescribes an action to write data to an Amazon S3 bucket.A builder forCfnTopicRule.S3ActionPropertyAn implementation forCfnTopicRule.S3ActionPropertyFor more information, see Signature Version 4 signing process .A builder forCfnTopicRule.SigV4AuthorizationPropertyAn implementation forCfnTopicRule.SigV4AuthorizationPropertyDescribes an action to publish to an Amazon SNS topic.A builder forCfnTopicRule.SnsActionPropertyAn implementation forCfnTopicRule.SnsActionPropertyDescribes an action to publish data to an Amazon SQS queue.A builder forCfnTopicRule.SqsActionPropertyAn implementation forCfnTopicRule.SqsActionPropertyStarts execution of a Step Functions state machine.A builder forCfnTopicRule.StepFunctionsActionPropertyAn implementation forCfnTopicRule.StepFunctionsActionPropertyDescribes how to interpret an application-defined timestamp value from an MQTT message payload and the precision of that value.A builder forCfnTopicRule.TimestampPropertyAn implementation forCfnTopicRule.TimestampPropertyDescribes an action that writes records into an Amazon Timestream table.A builder forCfnTopicRule.TimestreamActionPropertyAn implementation forCfnTopicRule.TimestreamActionPropertyMetadata attributes of the time series that are written in each measure record.A builder forCfnTopicRule.TimestreamDimensionPropertyAn implementation forCfnTopicRule.TimestreamDimensionPropertyThe value to use for the entry's timestamp.A builder forCfnTopicRule.TimestreamTimestampPropertyAn implementation forCfnTopicRule.TimestreamTimestampPropertyDescribes a rule.A builder forCfnTopicRule.TopicRulePayloadPropertyAn implementation forCfnTopicRule.TopicRulePayloadPropertyA key-value pair that you define in the header.A builder forCfnTopicRule.UserPropertyPropertyAn implementation forCfnTopicRule.UserPropertyPropertyA CloudFormationAWS::IoT::TopicRuleDestination.A fluent builder forCfnTopicRuleDestination.HTTP URL destination properties.An implementation forCfnTopicRuleDestination.HttpUrlDestinationSummaryPropertyThe properties of a virtual private cloud (VPC) destination.A builder forCfnTopicRuleDestination.VpcDestinationPropertiesPropertyAn implementation forCfnTopicRuleDestination.VpcDestinationPropertiesPropertyProperties for defining aCfnTopicRuleDestination.A builder forCfnTopicRuleDestinationPropsAn implementation forCfnTopicRuleDestinationPropsProperties for defining aCfnTopicRule.A builder forCfnTopicRulePropsAn implementation forCfnTopicRuleProps(experimental) An abstract action for TopicRule.Internal default implementation forIAction.A proxy class which represents a concrete javascript instance of this type.(experimental) Defines AWS IoT SQL.(experimental) The type returned from the `bind()` method inIotSql.A builder forIotSqlConfigAn implementation forIotSqlConfig(experimental) Represents an AWS IoT Rule.Internal default implementation forITopicRule.A proxy class which represents a concrete javascript instance of this type.(experimental) Defines an AWS IoT Rule in this stack.(experimental) A fluent builder forTopicRule.(experimental) Properties for defining an AWS IoT Rule.A builder forTopicRulePropsAn implementation forTopicRuleProps