> **Experimental**
>
> `@aws-cdk/aws-iot-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# IotSql

Defines AWS IoT SQL.

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/iot-sql.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0-alpha.0/packages/@aws-cdk/aws-iot-alpha/lib/iot-sql.ts#L21)

## Example

```ts
import * as sns from 'aws-cdk-lib/aws-sns';

const topic = new sns.Topic(this, 'MyTopic');

const topicRule = new iot.TopicRule(this, 'TopicRule', {
  sql: iot.IotSql.fromStringAsVer20160323(
    "SELECT topic(2) as device_id, year, month, day FROM 'device/+/data'",
  ),
  actions: [
    new actions.SnsTopicAction(topic, {
      messageFormat: actions.SnsActionMessageFormat.JSON, // optional property, default is SnsActionMessageFormat.RAW
    }),
  ],
});
```

## Initializer

```ts
new IotSql()
```

## Methods

- `bind(scope: Construct): IotSqlConfig` — Returns the IoT SQL configuration.

- `fromStringAsVer20151008(sql: string): IotSql // chainable` (static) — Uses the original SQL version built on 2015-10-08.

  **Parameters**

  - `sql` — The actual SQL-like syntax query.

  **Returns:** Instance of IotSql

- `fromStringAsVer20160323(sql: string): IotSql // chainable` (static) — Uses the SQL version built on 2016-03-23.

  **Parameters**

  - `sql` — The actual SQL-like syntax query.

  **Returns:** Instance of IotSql

- `fromStringAsVerNewestUnstable(sql: string): IotSql // chainable` (static) — Uses the most recent beta SQL version.

  If you use this version, it might
  introduce breaking changes to your rules.

  **Parameters**

  - `sql` — The actual SQL-like syntax query.

  **Returns:** Instance of IotSql
