AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: IoT -> Lambda -> DynamoDB
Resources:
  IoTFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs6.10
      CodeUri: src/
      Policies: AmazonDynamoDBFullAccess
      Environment:
        Variables:
          TABLE_NAME:
            Ref: Table
      Events:
        IoT:
          Type: IoTRule
          Properties:
            AwsIotSqlVersion: 2016-03-23
            Sql: "SELECT * FROM 'iot2ddb'"
  Table:
    Type: AWS::Serverless::SimpleTable
    Properties:
      PrimaryKey:
        Name: id
        Type: String
