AWS Lua Module

1. Overview

Lua wrapper for the aws-cpp-sdk library.

2. Module

2.1. Example Usage

require "aws.kinesis"

local reader = aws.kinesis.simple_consumer(streamName)
while true do
    local records, cp = reader:receive()
    for i, data in ipairs(records) do
      -- process data

2.2. Functions

2.2.1. simple_consumer

Creates a simple Kinesis consumer. This client will consume all shards and properly handle splits/merges. However, since it is not distributed it is limited to streams with up to ~50 shards on a 1Gb network interface.

local reader = aws.kinesis.simple_consumer(streamName, iteratorType, checkpoints, clientConfig, credentialProvider, roleArn)


  • streamName (string) Kinesis stream name
  • iteratorType (string/number/nil)
    • "TRIM_HORIZON" (default)
    • "LATEST"
    • number (time_t timestamp) converts to AT_TIMESTAMP iterator
  • checkpoints (string/nil) Value returned by receive()
  • clientConfig (table/nil)
  • credentialProvider (enum/nil)
    • INSTANCE (default)
    • CHAIN
    • ROLE
  • roleArn (nil/string) Only used when credentialProvider == ROLE


  • reader (userdata) or an error is thrown

2.2.2. simple_producer

Creates a simple Kinesis producer.

local writer = aws.kinesis.simple_producer(clientConfig, credentialProvider, roleArn)



  • writer (userdata) or an error is thrown

2.3. simple_consumer Methods

2.3.1. receive

Reads a set of records from the Kinesis stream.

local records, checkpoints = reader:receive()


  • none


  • records (array) Zero or more data records (throws on error)
  • checkpoints (string/nil) TSV of shardId, sequenceId items (one per line)

2.4. simple_producer Methods

2.4.1. send

Writes a record to the Kinesis stream.

local rv, err = writer:send(streamName, data, key)


  • streamName (string) Kinesis stream name
  • data (string) Data to send
  • key (string) Key for shard partitioning


  • rv (integer) Return value
    • 0 - success
    • -1 - error
    • -3 - retry
  • err (string/nil) nil on success

2.4.2. open_shard_count

Returns the open number of shards in the stream.

local cnt = writer:open_shard_count(streamName)


  • streamName (string) Kinesis stream name


  • cnt (integer/nil) Number of open shards (nil when the request can/should be retried, throws on fatal error)
  • err (string/nil) nil on success

results matching ""

    No results matching ""