Kinesis Example
The example program receives a Kinesis event with an array of records and forwards the message
from each record to a RequestBin endpoint.
Setup
Run the program locally:
go run main.go < event.json
View the the message in the RequestBin bucket:
Base64 Encoding
The record data on the Kinesis stream is Base64 encoded. Therefore in order to emulate a live message from Kinesis we'll manually encode the JSON payload.
Example JSON payload:
{"message": "Hello from Apex!"}
After Base64 encoding:
eyJtZXNzYWdlIjogIkhlbGxvIGZyb20gQXBleCEifQ==
The encoded data withing the event.json
payload:
{
"event": {
"Records": [
{
"eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961",
"eventVersion": "1.0",
"Kinesis": {
"partitionKey": "partitionKey-3",
"data": "eyJtZXNzYWdlIjogIkhlbGxvIGZyb20gQXBleCEifQ==", // Base64 encoded data
"kinesisSchemaVersion": "1.0",
"sequenceNumber": "49545115243490985018280067714973144582180062593244200961"
},
"invokeIdentityArn": "arn:aws:iam::EXAMPLE",
"eventName": "aws:kinesis:record",
"eventSourceARN": "arn:aws:kinesis:EXAMPLE",
"eventSource": "aws:kinesis",
"awsRegion": "us-east-1"
}
]
}
}