Fugue.AWS.Lambda.EventSourceMapping

This is the preferred interface for making Lambda Event Source Mappings with Fugue. If you want to manage a Lambda Event Source Mapping with Fugue, the newWithDynamoStream and newWithKinesisStream functions are the right place to start.

Module Members

newWithDynamoStream

(Function)

newWithDynamoStream

Example usage:

import Fugue.AWS as AWS
import Fugue.AWS.DynamoDB as DynamoDB
import Fugue.AWS.IAM as IAM
import Fugue.AWS.Lambda as Lambda

table: DynamoDB.Table.new {
  name: "myTable",
  region: AWS.Us-east-2,
  attributes: {
    "PropertyName": DynamoDB.S
  },
  schema: {
    "PropertyName": DynamoDB.HASH
  },
  provisionedThroughput: {
    read: 10,
    write: 10,
  },
  streamViewType: DynamoDB.NewImageView,
}

lambdaRole: IAM.Role {
  roleName: 'lambda-role',
  assumeRolePolicyDocument: IAM.Policy.AssumeRole.lambda,
  managedPolicies: [
    IAM.ManagedPolicy.external("arn:aws:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole"),
  ],
}

lambda1: Lambda.Function {
  functionName: 'lambda1',
  runtime: Lambda.Nodejs4_3,
  role: lambdaRole,
  handler: 'exports.myHandler',
  code: Lambda.Code.fromZipFile {
    path: "handler.zip",
  },
  region: AWS.Us-east-2,
}

eventSource: Lambda.EventSourceMapping.newWithDynamoStream {
  table: table,
  function: lambda1,
}

Type Signature

 fun { table: Table,
       function: Function,
       enabled: Optional<Bool>,
       batchSize: Optional<Int>,
       resourceId: Optional<String> } -> EventSourceMapping
Argument: table

The DynamoDB Table with the associated DynamoDB Stream that is the event source. Any record added to this stream could cause AWS Lambda to invoke your Lambda function, it depends on the BatchSize. AWS Lambda POSTs the stream event, containing records, to your Lambda function as JSON.

Type: Table

Argument: function

The Lambda function to invoke when AWS Lambda detects an event on the stream. Mutable.

Type: Function

Argument: enabled

Indicates whether AWS Lambda should begin polling the event source. By default, Enabled is true. Mutable.

Type: Optional<Bool>

Argument: batchSize

The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records. The default is 100 records. Mutable.

Type: Optional<Int>

Argument: resourceId

Resource ID of the resource to import with Fugue Import. This field is only honored on fugue run. This resource ID is the UUID. Mutable. Example: 6a2f41a3-c54c-fce8-32d2-0324e1c32e22

Type: Optional<String>

Returns:

A new Fugue.Core.AWS.Lambda.EventSourceMapping value configured to trigger on events from the specified DynamoDB stream.

Type: EventSourceMapping

newWithKinesisStream

(Function)

newWithKinesisStream

Example usage:

import Fugue.AWS as AWS
import Fugue.AWS.IAM as IAM
import Fugue.AWS.Kinesis as Kinesis
import Fugue.AWS.Lambda as Lambda

myStream: Kinesis.Stream.external("arn:aws:kinesis:us-east-2:123456789101:stream/myStream")

lambdaRole: IAM.Role {
  roleName: 'lambda-role',
  assumeRolePolicyDocument: IAM.Policy.AssumeRole.lambda,
  managedPolicies: [
    IAM.ManagedPolicy.external("arn:aws:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole"),
  ],
}

lambda1: Lambda.Function {
  functionName: 'lambda1',
  runtime: Lambda.Nodejs4_3,
  role: lambdaRole,
  handler: 'exports.myHandler',
  code: Lambda.Code.fromZipFile {
    path: "handler.zip",
  },
  region: AWS.Us-east-2,
}

kinesisEventSource: Lambda.EventSourceMapping.newWithKinesisStream {
  stream: myStream,
  function: lambda1,
  startingPosition: Lambda.Latest,
}

Type Signature

 fun { stream: Stream,
       function: Function,
       enabled: Optional<Bool>,
       batchSize: Optional<Int>,
       startingPosition: EventSourcePosition,
       startingPositionTimestamp: Optional<Int> } -> EventSourceMapping
Argument: stream

The Kinesis Stream that is the event source. Any record added to this stream could cause AWS Lambda to invoke your Lambda function, it depends on the BatchSize. AWS Lambda POSTs the stream event, containing records, to your Lambda function as JSON.

Type: Stream

Argument: function

The Lambda function to invoke when AWS Lambda detects an event on the stream. Mutable.

Type: Function

Argument: enabled

Indicates whether AWS Lambda should begin polling the event source. By default, Enabled is true. Mutable.

Type: Optional<Bool>

Argument: batchSize

The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records. The default is 100 records. Mutable.

Type: Optional<Int>

Argument: startingPosition

The position in the stream where AWS Lambda should start reading. For more information, see ShardIteratorType in the Amazon Kinesis API Reference.

Type: EventSourcePosition

Argument: startingPositionTimestamp

The timestamp of the data record from which to start reading. Used with startingPosition Lambda.AtTimestamp. If a record with this exact timestamp does not exist, the iterator returned is for the next (later) record. If the timestamp is older than the current trim horizon, the iterator returned is for the oldest untrimmed data record (Lambda.TrimHorizon)

Type: Optional<Int>

Returns:

A new Fugue.Core.AWS.Lambda.EventSourceMapping value configured to trigger on events from the specified kinesis stream.

Type: EventSourceMapping