service: forklift
frameworkVersion: "=1.8.0"

provider:
  name: aws
  runtime: nodejs4.3
  profile: ${opt:profile}
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/topics"

functions:
  createTopic:
    handler: src/handler.createTopic
    events:
      - http:
          path: topics
          method: post
          cors: true

resources:
  Resources:
    TopicsTable:
      Type: "AWS::DynamoDB::Table"
      DeletionPolicy: Retain
      Properties:
        TableName: "topics"
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1

service: forklift
frameworkVersion: "=1.8.0"

provider:
  name: aws
  runtime: nodejs4.3
  profile: ${opt:profile}
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
        - dynamodb:ListStreams
        - dynamodb:GetShardIterator
        - dynamodb:GetRecords
        - dynamodb:DescribeStream
      Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/*"

functions:
  createMessage:
    handler: src/handler.createMessage
    events:
      - http:
          path: messages
          method: post
          cors: true
  createTopic:
    handler: src/handler.createTopic
    events:
      - http:
          path: topics
          method: post
          cors: true
  notify:
    handler: src/handler.notify
    events:
      - stream: arn:aws:dynamodb:us-east-1:651189268295:table/messages/stream/2017-03-25T19:45:51.075

resources:
  Resources:
    MessagesTable:
      Type: "AWS::DynamoDB::Table"
      DeletionPolicy: Retain
      Properties:
        TableName: "messages"
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        StreamSpecification:
          StreamViewType: NEW_IMAGE
    TopicsTable:
      Type: "AWS::DynamoDB::Table"
      DeletionPolicy: Retain
      Properties:
        TableName: "topics"
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1

Add dynamo stream for message creation
Add dynamo stream for message creation

This will be a trigger for the notification system
