{
  "typeName" : "AWS::IoT::TopicRule",
  "description" : "Resource Type definition for AWS::IoT::TopicRule",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "additionalProperties" : false,
  "properties" : {
    "Arn" : {
      "type" : "string"
    },
    "RuleName" : {
      "type" : "string"
    },
    "TopicRulePayload" : {
      "$ref" : "#/definitions/TopicRulePayload"
    },
    "Tags" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    }
  },
  "definitions" : {
    "Action" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "S3" : {
          "$ref" : "#/definitions/S3Action"
        },
        "CloudwatchAlarm" : {
          "$ref" : "#/definitions/CloudwatchAlarmAction"
        },
        "CloudwatchLogs" : {
          "$ref" : "#/definitions/CloudwatchLogsAction"
        },
        "IotEvents" : {
          "$ref" : "#/definitions/IotEventsAction"
        },
        "Firehose" : {
          "$ref" : "#/definitions/FirehoseAction"
        },
        "Republish" : {
          "$ref" : "#/definitions/RepublishAction"
        },
        "StepFunctions" : {
          "$ref" : "#/definitions/StepFunctionsAction"
        },
        "DynamoDB" : {
          "$ref" : "#/definitions/DynamoDBAction"
        },
        "Http" : {
          "$ref" : "#/definitions/HttpAction"
        },
        "DynamoDBv2" : {
          "$ref" : "#/definitions/DynamoDBv2Action"
        },
        "CloudwatchMetric" : {
          "$ref" : "#/definitions/CloudwatchMetricAction"
        },
        "IotSiteWise" : {
          "$ref" : "#/definitions/IotSiteWiseAction"
        },
        "Elasticsearch" : {
          "$ref" : "#/definitions/ElasticsearchAction"
        },
        "Sqs" : {
          "$ref" : "#/definitions/SqsAction"
        },
        "Kinesis" : {
          "$ref" : "#/definitions/KinesisAction"
        },
        "IotAnalytics" : {
          "$ref" : "#/definitions/IotAnalyticsAction"
        },
        "Sns" : {
          "$ref" : "#/definitions/SnsAction"
        },
        "Lambda" : {
          "$ref" : "#/definitions/LambdaAction"
        },
        "Timestream" : {
          "$ref" : "#/definitions/TimestreamAction"
        },
        "Kafka" : {
          "$ref" : "#/definitions/KafkaAction"
        },
        "OpenSearch" : {
          "$ref" : "#/definitions/OpenSearchAction"
        },
        "Location" : {
          "$ref" : "#/definitions/LocationAction"
        }
      }
    },
    "ElasticsearchAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Type" : {
          "type" : "string"
        },
        "Index" : {
          "type" : "string"
        },
        "Id" : {
          "type" : "string"
        },
        "Endpoint" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "Type", "Endpoint", "Index", "Id", "RoleArn" ]
    },
    "KinesisAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "PartitionKey" : {
          "type" : "string"
        },
        "StreamName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "StreamName", "RoleArn" ]
    },
    "FirehoseAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "DeliveryStreamName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "Separator" : {
          "type" : "string"
        },
        "BatchMode" : {
          "type" : "boolean"
        }
      },
      "required" : [ "DeliveryStreamName", "RoleArn" ]
    },
    "AssetPropertyTimestamp" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TimeInSeconds" : {
          "type" : "string"
        },
        "OffsetInNanos" : {
          "type" : "string"
        }
      },
      "required" : [ "TimeInSeconds" ]
    },
    "CloudwatchMetricAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "MetricName" : {
          "type" : "string"
        },
        "MetricValue" : {
          "type" : "string"
        },
        "MetricNamespace" : {
          "type" : "string"
        },
        "MetricUnit" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "MetricTimestamp" : {
          "type" : "string"
        }
      },
      "required" : [ "MetricName", "MetricValue", "MetricNamespace", "MetricUnit", "RoleArn" ]
    },
    "AssetPropertyVariant" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "StringValue" : {
          "type" : "string"
        },
        "DoubleValue" : {
          "type" : "string"
        },
        "BooleanValue" : {
          "type" : "string"
        },
        "IntegerValue" : {
          "type" : "string"
        }
      }
    },
    "DynamoDBAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TableName" : {
          "type" : "string"
        },
        "PayloadField" : {
          "type" : "string"
        },
        "RangeKeyField" : {
          "type" : "string"
        },
        "HashKeyField" : {
          "type" : "string"
        },
        "RangeKeyValue" : {
          "type" : "string"
        },
        "RangeKeyType" : {
          "type" : "string"
        },
        "HashKeyType" : {
          "type" : "string"
        },
        "HashKeyValue" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "TableName", "HashKeyField", "HashKeyValue", "RoleArn" ]
    },
    "UserProperty" : {
      "type" : "object",
      "additionalProperties" : false,
      "required" : [ "Key", "Value" ],
      "properties" : {
        "Key" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 1024
        },
        "Value" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 1024
        }
      }
    },
    "UserProperties" : {
      "type" : "array",
      "minItems" : 1,
      "maxItems" : 100,
      "items" : {
        "$ref" : "#/definitions/UserProperty"
      }
    },
    "RepublishActionHeaders" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "PayloadFormatIndicator" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 1024
        },
        "ContentType" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 1024
        },
        "ResponseTopic" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 1024
        },
        "CorrelationData" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 1024
        },
        "MessageExpiry" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 1024
        },
        "UserProperties" : {
          "$ref" : "#/definitions/UserProperties"
        }
      }
    },
    "RepublishAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Qos" : {
          "type" : "integer"
        },
        "Topic" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "Headers" : {
          "$ref" : "#/definitions/RepublishActionHeaders"
        }
      },
      "required" : [ "Topic", "RoleArn" ]
    },
    "SnsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TargetArn" : {
          "type" : "string"
        },
        "MessageFormat" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "TargetArn", "RoleArn" ]
    },
    "StepFunctionsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "ExecutionNamePrefix" : {
          "type" : "string"
        },
        "StateMachineName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "StateMachineName", "RoleArn" ]
    },
    "SqsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RoleArn" : {
          "type" : "string"
        },
        "UseBase64" : {
          "type" : "boolean"
        },
        "QueueUrl" : {
          "type" : "string"
        }
      },
      "required" : [ "RoleArn", "QueueUrl" ]
    },
    "SigV4Authorization" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "ServiceName" : {
          "type" : "string"
        },
        "SigningRegion" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "ServiceName", "SigningRegion", "RoleArn" ]
    },
    "LambdaAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "FunctionArn" : {
          "type" : "string"
        }
      }
    },
    "PutAssetPropertyValueEntry" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "PropertyAlias" : {
          "type" : "string"
        },
        "PropertyValues" : {
          "type" : "array",
          "uniqueItems" : true,
          "items" : {
            "$ref" : "#/definitions/AssetPropertyValue"
          }
        },
        "AssetId" : {
          "type" : "string"
        },
        "EntryId" : {
          "type" : "string"
        },
        "PropertyId" : {
          "type" : "string"
        }
      },
      "required" : [ "PropertyValues" ]
    },
    "PutItemInput" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TableName" : {
          "type" : "string"
        }
      },
      "required" : [ "TableName" ]
    },
    "S3Action" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "BucketName" : {
          "type" : "string"
        },
        "Key" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "CannedAcl" : {
          "$ref" : "#/definitions/CannedAccessControlList"
        }
      },
      "required" : [ "BucketName", "Key", "RoleArn" ]
    },
    "AssetPropertyValue" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Value" : {
          "$ref" : "#/definitions/AssetPropertyVariant"
        },
        "Timestamp" : {
          "$ref" : "#/definitions/AssetPropertyTimestamp"
        },
        "Quality" : {
          "type" : "string"
        }
      },
      "required" : [ "Value", "Timestamp" ]
    },
    "DynamoDBv2Action" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "PutItem" : {
          "$ref" : "#/definitions/PutItemInput"
        },
        "RoleArn" : {
          "type" : "string"
        }
      }
    },
    "IotEventsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "InputName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "MessageId" : {
          "type" : "string"
        },
        "BatchMode" : {
          "type" : "boolean"
        }
      },
      "required" : [ "InputName", "RoleArn" ]
    },
    "HttpAuthorization" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Sigv4" : {
          "$ref" : "#/definitions/SigV4Authorization"
        }
      }
    },
    "TopicRulePayload" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RuleDisabled" : {
          "type" : "boolean"
        },
        "ErrorAction" : {
          "$ref" : "#/definitions/Action"
        },
        "Description" : {
          "type" : "string"
        },
        "AwsIotSqlVersion" : {
          "type" : "string"
        },
        "Actions" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Action"
          }
        },
        "Sql" : {
          "type" : "string"
        }
      },
      "required" : [ "Actions", "Sql" ]
    },
    "CloudwatchAlarmAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "StateValue" : {
          "type" : "string"
        },
        "AlarmName" : {
          "type" : "string"
        },
        "StateReason" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "AlarmName", "StateReason", "StateValue", "RoleArn" ]
    },
    "CloudwatchLogsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "LogGroupName" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        },
        "BatchMode" : {
          "type" : "boolean"
        }
      },
      "required" : [ "LogGroupName", "RoleArn" ]
    },
    "IotAnalyticsAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RoleArn" : {
          "type" : "string"
        },
        "ChannelName" : {
          "type" : "string"
        },
        "BatchMode" : {
          "type" : "boolean"
        }
      },
      "required" : [ "ChannelName", "RoleArn" ]
    },
    "HttpActionHeader" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Value" : {
          "type" : "string"
        },
        "Key" : {
          "type" : "string"
        }
      },
      "required" : [ "Value", "Key" ]
    },
    "IotSiteWiseAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RoleArn" : {
          "type" : "string"
        },
        "PutAssetPropertyValueEntries" : {
          "type" : "array",
          "uniqueItems" : true,
          "items" : {
            "$ref" : "#/definitions/PutAssetPropertyValueEntry"
          }
        }
      },
      "required" : [ "PutAssetPropertyValueEntries", "RoleArn" ]
    },
    "HttpAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "ConfirmationUrl" : {
          "type" : "string"
        },
        "Headers" : {
          "type" : "array",
          "uniqueItems" : true,
          "items" : {
            "$ref" : "#/definitions/HttpActionHeader"
          }
        },
        "Url" : {
          "type" : "string"
        },
        "Auth" : {
          "$ref" : "#/definitions/HttpAuthorization"
        }
      },
      "required" : [ "Url" ]
    },
    "TimestreamAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RoleArn" : {
          "type" : "string"
        },
        "DatabaseName" : {
          "type" : "string"
        },
        "TableName" : {
          "type" : "string"
        },
        "Dimensions" : {
          "$ref" : "#/definitions/TimestreamDimensionsList"
        },
        "Timestamp" : {
          "$ref" : "#/definitions/TimestreamTimestamp"
        }
      },
      "required" : [ "RoleArn", "DatabaseName", "TableName", "Dimensions" ]
    },
    "KafkaAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "DestinationArn" : {
          "type" : "string"
        },
        "Topic" : {
          "type" : "string"
        },
        "Key" : {
          "type" : "string"
        },
        "Partition" : {
          "type" : "string"
        },
        "ClientProperties" : {
          "type" : "object",
          "additionalProperties" : false,
          "patternProperties" : {
            ".*" : {
              "type" : "string"
            }
          },
          "minProperties" : 1
        }
      },
      "required" : [ "DestinationArn", "Topic", "ClientProperties" ]
    },
    "OpenSearchAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Type" : {
          "type" : "string"
        },
        "Index" : {
          "type" : "string"
        },
        "Id" : {
          "type" : "string"
        },
        "Endpoint" : {
          "type" : "string"
        },
        "RoleArn" : {
          "type" : "string"
        }
      },
      "required" : [ "Type", "Endpoint", "Index", "Id", "RoleArn" ]
    },
    "LocationAction" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "RoleArn" : {
          "type" : "string"
        },
        "TrackerName" : {
          "type" : "string"
        },
        "DeviceId" : {
          "type" : "string"
        },
        "Latitude" : {
          "type" : "string"
        },
        "Longitude" : {
          "type" : "string"
        },
        "Timestamp" : {
          "$ref" : "#/definitions/Timestamp"
        }
      },
      "required" : [ "RoleArn", "TrackerName", "DeviceId", "Latitude", "Longitude" ]
    },
    "CannedAccessControlList" : {
      "type" : "string",
      "enum" : [ "private", "public-read", "public-read-write", "aws-exec-read", "authenticated-read", "bucket-owner-read", "bucket-owner-full-control", "log-delivery-write" ]
    },
    "RoleArn" : {
      "type" : "string"
    },
    "Tag" : {
      "type" : "object",
      "properties" : {
        "Key" : {
          "type" : "string"
        },
        "Value" : {
          "type" : "string"
        }
      },
      "additionalProperties" : false,
      "required" : [ "Key", "Value" ]
    },
    "TimestreamDimensionsList" : {
      "type" : "array",
      "minItems" : 1,
      "maxItems" : 128,
      "items" : {
        "$ref" : "#/definitions/TimestreamDimension"
      }
    },
    "TimestreamDimension" : {
      "type" : "object",
      "properties" : {
        "Name" : {
          "type" : "string"
        },
        "Value" : {
          "type" : "string"
        }
      },
      "additionalProperties" : false,
      "required" : [ "Name", "Value" ]
    },
    "TimestreamTimestamp" : {
      "type" : "object",
      "properties" : {
        "Value" : {
          "type" : "string"
        },
        "Unit" : {
          "type" : "string"
        }
      },
      "additionalProperties" : false,
      "required" : [ "Value", "Unit" ]
    },
    "Timestamp" : {
      "type" : "object",
      "properties" : {
        "Value" : {
          "type" : "string"
        },
        "Unit" : {
          "type" : "string"
        }
      },
      "additionalProperties" : false,
      "required" : [ "Value" ]
    }
  },
  "required" : [ "TopicRulePayload" ],
  "createOnlyProperties" : [ "/properties/RuleName" ],
  "primaryIdentifier" : [ "/properties/RuleName" ],
  "readOnlyProperties" : [ "/properties/Arn" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "iam:PassRole", "iot:CreateTopicRule", "iot:GetTopicRule" ]
    },
    "read" : {
      "permissions" : [ "iot:GetTopicRule", "iot:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "iot:ReplaceTopicRule", "iot:ListTagsForResource", "iot:TagResource", "iot:UntagResource" ]
    },
    "delete" : {
      "permissions" : [ "iot:GetTopicRule", "iot:DeleteTopicRule" ]
    },
    "list" : {
      "permissions" : [ "iot:ListTopicRules" ]
    }
  }
}